This repository is to track my progress of learning DSA.
Adhere to this 90-day roadmap (https://whimsical.com/dsa-in-90-days-EmPkf5utoFGRMnRqJjM6YV) and ensure that all the problems in Striver's SDE sheet (https://takeuforward.org/interviews/strivers-sde-sheet-top-coding-interview-problems/) are solved in parallel.
- Recursion Playlist https://www.youtube.com/watch?v=AxNNVECce8c&list=PLgUwDviBIf0rGlzIn_7rsaR2FQ5e6ZOL9&index=7
Problem Name | Link | My Code | |
---|---|---|---|
1. | Subsets | Link | Code |
2. | Subset Sum | Link | Code |
Explored the all subsets problem, with a slight variation i.e. the usage of a for loop in the recursive util method. Reference: https://www.youtube.com/watch?v=kYY9DotIKlo&list=PLzffTJx5aHaSJ4XaG55cI3Z0VrNOyLWpH
Problem Name | Link | My Code | |
---|---|---|---|
1. | Subsets | Link | Code |
2. | Subset 2 | Link | Code |
3. | Combination sum 1 | Link | Code |
4. | Combination sum 2 | Link | Code |
(Cheat day)
- Power of three - https://leetcode.com/problems/power-of-three
- Power of four - https://leetcode.com/problems/power-of-four
- Fibonacci - https://leetcode.com/problems/fibonacci-number
- Explored the Palindrome Partitioning problem, tried to devise a solution, but did not work. Will have to work work out the steps after having a look at the solution.
- Watched the tutorial for k-th permutation - https://www.youtube.com/watch?v=wT7gcXLYoao&list=PLgUwDviBIf0p4ozDR_kJJkONnb1wdx2Ma&index=56
- Print all permutations of an array - https://leetcode.com/problems/permutations/
- Palindrome Partitioning - https://leetcode.com/problems/palindrome-partitioning/
- K-th Permutation (Brute Force) - https://leetcode.com/problems/permutation-sequence/
-
stringstream ss; copy(intVector.begin(), intVector.end(), ostream_iterator<int>(ss, "")); string s = ss.str(); // Converts a vector<int> to a string
-
iota(intVector.begin(), intVector.end(), 1); // Generates an integer vector from 1 to intVector.size()
-
- K-th Permutation (Optimal) - https://leetcode.com/problems/permutation-sequence/
- N-Queens - https://leetcode.com/problems/n-queens/
- Sudoku Solver - https://leetcode.com/problems/sudoku-solver/
- M-Coloring - https://www.codingninjas.com/codestudio/problems/981273?topList=striver-sde-sheet-problems&utm_source=striver&utm_medium=website&leftPanelTab=0
- Rat in a Maze - https://www.codingninjas.com/codestudio/problems/758966?topList=striver-sde-sheet-problems&utm_source=striver&utm_medium=website&leftPanelTab=0
- Word break - https://bit.ly/3FxgW92
- Pow(x, n) - https://leetcode.com/problems/powx-n/
- Different Ways to Add Parantheses - https://leetcode.com/problems/different-ways-to-add-parentheses/
- Decode String - https://leetcode.com/problems/decode-string/
- Set matrix zeroes - https://leetcode.com/problems/set-matrix-zeroes/
- Pascal's Triangle - https://leetcode.com/problems/pascals-triangle/
- Stock Buy and Sell - https://leetcode.com/problems/best-time-to-buy-and-sell-stock/
- Maximum Subarray Sum (Kadane's Algorithm) - https://leetcode.com/problems/maximum-subarray/
- Next Permutation - https://leetcode.com/problems/next-permutation/
- Sort arrays of 0s, 1s and 2s (Solved using Naive and Dutch National Flag Algo approaches) - https://leetcode.com/problems/sort-colors/
- Rotate Image by 90 degree - https://leetcode.com/problems/rotate-image/
- Merge Intervals - https://leetcode.com/problems/merge-intervals/
- Merge sorted arrays - https://leetcode.com/problems/merge-sorted-array/
- Find the duplicate number - https://leetcode.com/problems/find-the-duplicate-number/
- Missing and repeating numbers - https://bit.ly/3Gs6wZu
- Count Inversions - https://bit.ly/339fFb7 (Revisit the merge method Line 27)
- Search a 2D Matrix - https://leetcode.com/problems/search-a-2d-matrix/
- Majority Element greater than n/2 - https://leetcode.com/problems/majority-element/
- Two Sum - https://leetcode.com/problems/two-sum/
- Majority element greater than n/3 (extended Boyer Moore's voting algo) - https://leetcode.com/problems/majority-element-ii/
- Unique Paths - https://leetcode.com/problems/unique-paths/
- Reverse Pairs - https://leetcode.com/problems/reverse-pairs/
- Longest consecutive sequence - https://leetcode.com/problems/longest-consecutive-sequence/
- 4 sum - https://leetcode.com/problems/4sum/
- In case there is a need to have set of tuples,
multiset<int> m;
- Convert multiset to vector
multiset<int> m; vector<int> v(m.begin(), m.end());
- Longest subarray sum of 0 - https://bit.ly/31UHoeM (prefix sum approach with map<int,int>)
- Count subarrays with given XOR - https://bit.ly/3fp24yN
- Length of longest substring without repeating characters - https://leetcode.com/problems/longest-substring-without-repeating-characters/
- Reverse linked list (both iterative and recursive) - https://leetcode.com/problems/reverse-linked-list/
- Middle of linked list - https://leetcode.com/problems/middle-of-the-linked-list/
- Merge two sorted linked lists - https://leetcode.com/problems/merge-two-sorted-lists/
- Remove nth node from the last - https://leetcode.com/problems/remove-nth-node-from-end-of-list/
- Add two numbers - https://leetcode.com/problems/add-two-numbers/
- Delete node in a linked list O(1) - https://leetcode.com/problems/delete-node-in-a-linked-list/
- Linked List Cycle - https://leetcode.com/problems/linked-list-cycle/
- Intersection of two linked lists - https://leetcode.com/problems/intersection-of-two-linked-lists/
- Palindrome linked list - https://leetcode.com/problems/palindrome-linked-list/
- Find starting point of loop of linked list - https://leetcode.com/problems/linked-list-cycle-ii/
- Flatten linked list - https://bit.ly/3nqtEA1
- Remove duplicates from sorted array - https://leetcode.com/problems/remove-duplicates-from-sorted-array/
- Maximum consecutive ones - https://leetcode.com/problems/max-consecutive-ones/
- Rotate List - https://leetcode.com/problems/rotate-list/
- Reverse nodes in k-group - https://leetcode.com/problems/reverse-nodes-in-k-group/
- 3Sum - https://leetcode.com/problems/3sum/
- Copy list with random pointer - https://leetcode.com/problems/copy-list-with-random-pointer/
- Implement queue using arrays - https://bit.ly/3KbIjIW
- Implement stack using queues - https://leetcode.com/problems/implement-stack-using-queues/
- Valid paretheses - https://leetcode.com/problems/valid-parentheses/
- Valid palindrome - https://leetcode.com/problems/valid-palindrome/
- Trapping Rain Water (Brute Force, TLE) - https://leetcode.com/submissions/detail/754308761/
- Trapping Rain Water ( O(N) time and O(N) space) - https://leetcode.com/submissions/detail/754347851/
- Trapping Rain Water ( O(N) time and constant space) - https://leetcode.com/problems/trapping-rain-water/
- Next greater element - https://leetcode.com/problems/next-greater-element-i/
- Sort a stack - https://bit.ly/3nptF7k
- Next smaller element - https://bit.ly/3K6WVtb
- Min Stack - https://leetcode.com/problems/min-stack/
- LRU Cache - https://leetcode.com/problems/lru-cache/
- Sliding window maximum - https://leetcode.com/problems/sliding-window-maximum/
- Celebrity Problem - https://bit.ly/3GuImxi
- Largest Rectangle in histogram - https://leetcode.com/problems/largest-rectangle-in-histogram/