I have linked the solutions to the problems I've solved.
Array
Array
TODO:
- Transpose of matrix
- Rotate Image
- Maximum Value in increasing - decreasing array
- Matrix Rotation in place
- Celebrity Problem
- Quicksort implementation - Kth smallest
- Median of two sorted array
- Maximum of all subarrays of size K
Sliding Window: Fixed
Sliding Window: Variable
Stack & Queue
Heap
Greedy
Linked List
Recursion & Backtracking
- Subsets-I
- Subsets-II
- Permutation-I
- Permutation-II
- Combination-sum-I
- Combination-sum-II
- N Queens - I
- Word Search
- Generate Correct Parenthesis
TODO:
Tree
- InOrder Traversal- Recursive & Iterative
- Preorder Traversal - Recursive & Iterative
- Postorder Traversal - Recursive & Iterative
- kth smallest in BST
- Sum root to leaf
- Boundary nodes
- Depth of a BT
- Sum of all nodes
- Level order traversal;
- ZigZag order traversal
- Odd even level difference
- Count the number of leaf nodes
- Diameter of a Btree
- Is the BTree Balanced
- Left View
- Right View
- Vertical Order Traversal
- Top View
- Bottom View
- Path to Node
- Max Path sum
- Construct a binary tree from preorder
- Construct a binary tree from inorder and preorder
- Same Tree
- Is the BTree Symmetric
- Least common ancestor - Binary Tree
- Least common ancestor - Binary Search Tree
- Maximum width of a Binary Tree
- Serialize and Deserialize a Btree
- Is sub-tree
- Good Nodes
- Invert a BTree
- Merge two BTree
- Sorted Array to Balanced BTree
- Triangle min path sum
- Valid BTree
- House Robber III
- Bottom Left Tree Value
- Trim BST
- Has Path Sum
- BST Iterator
- Populating Next Right Pointers
TODO:
- [Siblings & Cousins]
- [Burn a tree]
Dynamic Programming
Patterns
Mix DP
- Climbing Stairs
- House Robber
- House Robber II
- Min cost climbing stairs
- Decode Ways
- Pascal's Triangle
- Unique Paths
- Word Break
- Buy and Sell Stock I
- Buy and Sell Stock II
- Buy and Sell Stock III
- Buy and Sell Stock IV
- Best time to buy/sell stock with cooldown
- Jump Game - II
- Jump Game - III
- Unique BST
- Perfect Squares
- Regular Expression Matching
- All Possible Full Binary Tree
- Stone Game I
- Integer Break
I. 2-DP::
- Interleaving String
- Longest Increasing Path in matrix
- Distinct Subsequence
- Unique Paths II
- Minimum Path Sum
- Maximal Squared
- Paint Houses - I
II. 0/1 Knapsack
- Knapsack problem
- Subset sum problem
- Count of subset problem - Perfect Sum
- Equal Partition problem
- Minimum subset sum difference
- No. of subset with given difference
- Target sum
III. Unbounded Knapsack
IV. Subsequence - Substring
V Partition DP
Graphs
Graph I
No | Questions | Way |
---|---|---|
1. | BFS - Implementation | Queue + visited[] |
2. | DFS - Implementation | Visited[] |
3. | Number of Provinces | BFS - disconnected components |
4. | Number of Islands | Modified Number of Provinces + 1-degree traversal up, right, down, left |
5. | Flood Fill | Modified Traversal |
6. | Rotten Oranges | Modified BFS - With a Time Counter |
7. | Detect cycle using BFS - Undirected Graph | Neighbour is visted => Neighbour is current node's parent |
8. | Detect cycle using DFS - Undirected Graph | Neighbour is visted => Neighbour is current node's parent |
9. | Detect cycle using DFS - Directed Graph | visited[] + dfsVisited[] (backtracking) : tracks visited path |
10. | Topological Sort - DFS | visited[] + stk.push(node) backtracking |
11. | Topological Sort - BFS - Kahn's Algorithm | indegree[] , Kahn Algorithm |
12. | Detect cycle using DFS - Directed Graph | indegree[] or Kahn Algorithm |
13. | Bipartite Graph - BFS | color[], color[currNode] == color[neighbour] |
14. | Bipartite Graph - DFS | color[], color[currNode] == color[neighbour] |
15. | Clone Graph | DFS + Mapping GivenNode to ClonedNode |
Graph II
Note: Shortest Path Question will require a
distance[]
for every problem
No | Questions | Way |
---|---|---|
1. | Shortest Path - Non-Weighted + Undirected Graph | BFS + parent[] |
2. | Shortest Path - Weighted + Directed Graph | Topological Stack + parent[] |
3. | Shortest Path - Weighted Graph( UDG) | Djikstra Algorithm |
4. | Shortest Path - In Binary Maze | Djikstra Algorithm |
TODO:
- Templates
- Construct Graph from given edges