Comprehensive Data Structures and Algorithms reference with 200+ implementations covering all topics from basic to advanced competitive programming.
Reverse, Find Max/Min, Kadane's Algorithm, Rotate Array, Two Sum, Three Sum, Remove Duplicates, Move Zeros, Find Missing Number, Find Duplicate (Floyd's), Merge Sorted Arrays, Sliding Window Maximum, Subarray with Sum, Longest Subarray Sum K, Prefix Sum, Product Except Self, Trapping Rain Water, Container With Most Water, Next Permutation, Search Rotated Array, Majority Element (Boyer-Moore), Stock Buy Sell
Palindrome Check, Anagram Check, Reverse String, Reverse Words, Longest Palindromic Substring, KMP Pattern Matching, Rabin-Karp, Z Algorithm, Longest Common Prefix, String to Integer (atoi), Group Anagrams, Valid Parentheses, Longest Substring Without Repeating, Count and Say, Remove Duplicates, String Permutations
Insert at Head, Reverse Linked List, Detect Cycle (Floyd's), Find Middle, Merge Two Sorted Lists, Remove Nth from End, Palindrome Check
Valid Parentheses, Next Greater Element, Min Stack (O(1) getMin), Evaluate Postfix Expression, Largest Rectangle in Histogram
Circular Queue, Queue Using Stacks, First Non-Repeating Character, Sliding Window Maximum, Reverse Queue, Generate Binary Numbers
Factorial, Fibonacci, Power (Fast Exponentiation), Generate Subsets, Generate Permutations, Tower of Hanoi, N-Queens Problem, Solve N-Queens, Combination Sum
Bubble Sort O(nΒ²), Selection Sort O(nΒ²), Insertion Sort O(nΒ²), Merge Sort O(n log n), Quick Sort O(n log n), Heap Sort O(n log n), Counting Sort
Linear Search, Binary Search (Iterative), Binary Search (Recursive), First Occurrence, Last Occurrence, Search in Rotated Array, Find Peak Element, Square Root (Binary Search)
Two Sum, Subarray with Sum 0, Longest Subarray with Sum K, Count Distinct Elements, First Repeating Element, Group Anagrams
Inorder Traversal, Preorder Traversal, Postorder Traversal, Level Order Traversal (BFS), Height of Tree, Diameter of Tree, Lowest Common Ancestor (LCA), Check if Balanced, Mirror Tree, Path Sum
Insert Node, Search Node, Delete Node, Find Min Value, Validate BST, Kth Smallest Element, LCA in BST, Sorted Array to BST
Min Heap Implementation, Max Heap (priority_queue), Kth Largest Element, Merge K Sorted Arrays, Find Median from Stream
DFS (Depth-First Search), BFS (Breadth-First Search), Cycle Detection (Directed), Topological Sort, Dijkstra's Shortest Path, Bellman-Ford Algorithm, Floyd-Warshall (All Pairs), Prim's MST, Kruskal's MST, Tarjan's SCC, Find Bridges, Articulation Points, Bipartite Check
Fibonacci (Memoization), 0/1 Knapsack, Unbounded Knapsack, Longest Common Subsequence (LCS), Longest Common Substring, Longest Increasing Subsequence (LIS), Longest Palindromic Subsequence, Edit Distance (Levenshtein), Matrix Chain Multiplication (MCM), Coin Change - Min Coins, Coin Change - Ways, Subset Sum, Partition Equal Subset, Rod Cutting, Egg Dropping, Palindrome Partitioning (Min Cuts), Climbing Stairs, House Robber, Minimum Path Sum (Grid), Unique Paths (Grid)
Activity Selection, Fractional Knapsack, Minimum Coins (Greedy), Job Sequencing, Minimum Platforms
Sudoku Solver, Rat in Maze, Generate Parentheses, Word Search, Graph Coloring
Insert Word, Search Word, Starts With (Prefix), Delete Word, Longest Common Prefix
Red-Black Tree (Insert with rotations), AVL Tree (Insert with balancing)
Check if Bit is Set, Set Bit, Clear Bit, Toggle Bit, Check Power of 2, Count Set Bits (Brian Kernighan's), Find Single Number (XOR), Two Single Numbers, Reverse Bits, Swap Without Temp, Find Missing Number (XOR), Generate All Subsets, Maximum XOR of Two Numbers, Count Bits from 0 to n, Add Binary Strings, Divide Using Bit Manipulation
Merge Sort, Quick Sort, Binary Search (Recursive), Maximum Subarray (D&C), Count Inversions, Closest Pair of Points, Strassen's Matrix Multiplication, Karatsuba Multiplication, Median of Two Sorted Arrays, Kth Smallest Element
Range Sum Query, Range Min/Max Query, Lazy Propagation (Range Updates)
DSU with Path Compression, Kruskal's MST using DSU, Cycle Detection, Count Connected Components, Friend Circles
GCD (Euclidean), LCM, Prime Check, Sieve of Eratosthenes, Prime Factorization, Modular Exponentiation, Modular Inverse, nCr (Combinations), Fibonacci (Matrix Exponentiation), Catalan Numbers, Extended GCD, Count Divisors, Sum of Divisors, Euler's Totient Function, Fast Multiplication (Karatsuba)
Each topic folder contains:
- README.md - Concepts, theory, time/space complexity, important problems
- Code file (.cpp) - Clean, minimal implementations of all algorithms
DSA notes/
βββ 01_Arrays/
β βββ arrays.cpp
β βββ README.md
βββ 02_Strings/
β βββ strings.cpp
β βββ README.md
βββ ... (21 more topics)
βββ README.md (this file)
- Navigate to any topic folder (e.g.,
01_Arrays/) - Read README.md for theory, complexity analysis, and problem patterns
- Study the .cpp file for implementations
- Practice problems mentioned in each README
- Implement yourself before checking solutions
β Arrays β Strings β Linked Lists β Stacks β Queues
Focus: Basic data structures, two pointers, sliding window
β Recursion β Sorting β Searching β Hashing β Trees β BST
Focus: Recursion patterns, sorting algorithms, tree traversals
β Heaps β Graphs β Dynamic Programming β Greedy β Backtracking
Focus: Graph algorithms, DP patterns, optimization techniques
β Tries β Advanced Trees β Bit Manipulation β Divide & Conquer β Segment Trees β DSU β Math Algorithms
Focus: Advanced data structures, competitive programming
| Data Structure/Algorithm | Time Complexity | Space Complexity |
|---|---|---|
| Array Access | O(1) | O(1) |
| Binary Search | O(log n) | O(1) |
| Merge/Quick Sort | O(n log n) | O(n) / O(log n) |
| Hash Table Insert/Search | O(1) avg | O(n) |
| BFS/DFS | O(V+E) | O(V) |
| Dijkstra | O((V+E) log V) | O(V) |
| Dynamic Programming | O(nΒ²) typical | O(n) to O(nΒ²) |
| Segment Tree Query | O(log n) | O(n) |
| DSU Find/Union | O(Ξ±(n)) β O(1) | O(n) |
β Understand patterns, not just memorize code β Practice complexity analysis for every algorithm β Implement yourself before checking solutions β Solve variations of each problem β Focus on problem-solving approach over syntax β Review regularly - spaced repetition works β Time yourself when practicing
- β 2nd Year Engineering DSA Course
- β DAA (Design & Analysis of Algorithms)
- β Competitive Programming (Codeforces, CodeChef, LeetCode)
- β Interview Preparation (FAANG, Product Companies)
- β College Exams & Placements
- Total Topics: 23
- Total Algorithms: 200+
- Lines of Code: 5000+
- Coverage: Basic β Advanced β Competitive Programming
- Language: C++ (STL optimized)
Arrays: Kadane's, Two Sum, Trapping Water, Stock Buy Sell
Strings: KMP, Longest Palindrome, Valid Parentheses
Linked List: Reverse, Cycle Detection, Merge
Trees: All Traversals, LCA, Diameter, Validate BST
Graphs: DFS, BFS, Dijkstra, Topological Sort
DP: 0/1 Knapsack, LCS, LIS, MCM, Coin Change, Edit Distance
Backtracking: N-Queens, Sudoku
Advanced: Segment Trees, DSU, Bit Manipulation
Google: DP, Graphs, Trees, Math
Amazon: Arrays, Strings, DP, Trees
Microsoft: Trees, Graphs, DP, Recursion
Facebook/Meta: Graphs, DP, Backtracking
Competitive Programming: All topics, especially Math, Bit Manipulation, Segment Trees
All implementations are minimal, efficient, and interview-ready! Good luck with your DSA journey! ππ