Short Notes: Data Structures and Algorithms (DSA)
### 1. Arrays & Strings
- **Kadane's Algorithm**: Maximum subarray sum in O(n).
- **Sliding Window**: Longest substring without repeating characters.
- **Common Repeated Question**: Find the first repeating element in an array.
### 2. Linked List
- **Reverse a Linked List** (Iterative & Recursive).
- **Floyd's Cycle Detection Algorithm**: Detect and remove loop in O(n).
- **Common Repeated Question**: Find the middle element of a linked list in O(n).
### 3. Stacks & Queues
- **Next Greater Element**: Find the next greater element for each element in an array.
- **LRU Cache Implementation**: Least Recently Used Cache using Doubly Linked List.
- **Common Repeated Question**: Implement a stack using two queues.
### 4. Recursion & Backtracking
- **N-Queens Problem**: Place N queens on an NxN chessboard.
- **Subset Sum Problem**: Find all subsets of a set that sum to a given value.
- **Common Repeated Question**: Generate all permutations of a string.
### 5. Sorting & Searching
- **Quick Sort & Merge Sort**: Divide & Conquer sorting techniques.
- **Binary Search Variants**: First and last occurrence of an element in a sorted array.
- **Common Repeated Question**: Search an element in a rotated sorted array.
### 6. Dynamic Programming
- **Longest Common Subsequence (LCS)**: Used in text comparison algorithms.
- **0/1 Knapsack Problem**: Maximize profit with given weight constraints.
- **Common Repeated Question**: Count ways to reach the nth stair.
### 7. Graph Algorithms
- **Dijkstra's Algorithm**: Shortest path in a weighted graph.
- **Topological Sorting**: Using Kahn's Algorithm (BFS) or DFS.
- **Common Repeated Question**: Detect cycle in a directed graph.
### 8. Trees & Binary Search Trees (BST)
- **Inorder, Preorder, Postorder Traversal**: Depth-first traversals.
- **Lowest Common Ancestor (LCA)**: Find the LCA of two nodes in BST.
- **Common Repeated Question**: Convert a binary tree to a doubly linked list.
### 9. Hashing
- **HashMap & HashSet Operations**: Implement using chaining & open addressing.
- **Common Repeated Question**: Find the longest consecutive sequence in an array.
### 10. Greedy Algorithms
- **Huffman Coding**: Used in data compression.
- **Activity Selection Problem**: Select max activities without overlap.
- **Common Repeated Question**: Minimum number of coins to make a given amount.