dsa
dsa copied to clipboard
My Codes and Solutions to coding interview problems on LeetCode, AlgoExpert, Educative and other interview preparation websites
Interview Preparation
Arrays
- [ ] Sieve
- [ ] Catalan Numbers
- [x] Sliding Window Technique
- [ ] Recursion and Backtracking
- [ ] Binary Search (TopCoder)
- [ ] BacktoBackSWE Playlist
- [x] Tortoise and Hare Pointer
Trees
- [x] Flatten Tree
- [x] Height of Tree
- [x] Iterative Traversals
- [x] Lowest Common Ancestor
- [x] Level Order Traversal
- [x] Diameter of a Binary Tree
- [x] Recursive Traversals
- [x] Diagonal Traversal
- [x] Vertical Traversal
- [x] Serialize and Deserialize Trees
- [x] Other BackToBackSWE Ones
Graphs
- [x] BFS Problems
- [ ] Graph coloring/Bipartition
- [x] DFS Problems
- [ ] Topological Sort
- [ ] Union Find
- [ ] Find Shortest Path (Dijkstra's/Bellman Ford
- [ ] BackToBackSWE Playlist
- [ ] LeetCode Graphs Patterns
Searching and Sorting
- [ ] Bubble Sort
- [ ] Insertion Sort
- [ ] Quick Sort
- [ ] Merge Sort
- [ ] Inversion Count
- [ ] Count Numbers Larger and Smaller than Self
- [ ] Radix Sort
- [ ] Count Sort
- [ ] Heap Sort
- [ ] Binary Search
- [ ] BackToBackSWE Playlist
Linked Lists
- [x] Insert
- [x] Delete Nth Node
- [x] Reverse
- [x] Merge Two Sorted Linked List
- [x] Fast Pointer, Slow Pointer technique
- [ ] Doubly Linked List
- [ ] BackToBackSWE Playlist
Hashing
- [x] Various Types of Hashing
Bit Manipulation
- [x] Basics
- [x] BitMasking
- [x] Powerset and Find tha nums
One Month Challenge :')
Difficulty Levels solved :
π’ Easy: 70
π‘ Medium: 60
π΄ Hard:2
β«οΈ Very Hard: 0
π Good to review
Total - 132
Day 0
Adding solutions to all problems I have completed today
Focus for today: Arrays, Strings
LeetCode
- π’ Remove Duplicates from Sorted Array Notes: Use Hash Map!
- π’ Rotate Array Notes: Recursion or (i+k)%n Index!
- π’ Reverse String Notes: Recursion!
AlgoExpert
- π’ Palindrome Check Notes: 2 Pointer's (Best)!
Educative
Sliding Window Technique Pattern
- π’ Average of all contiguous subarrays of size βKβ
Day 1
Focus for today: STL/ Linked Lists
LeetCode
- π‘ Remove Nth Node From End of List Notes: π use fast and slow pointer's
- π’ Delete Node in a Linked List Notes: free(temp) doesn't works!
AlgoExpert
- π‘ Linked List Construction Notes: Nothing π
Educative
Sliding Window Technique Pattern Notes: Mostly use HashMaps or HashSets!
- π‘ Longest Substring with K Distinct Characters
- π’ Maximum Sum Subarray of Size K
- π’ Smallest Subarray with a given sum
Day 2
Focus for today: Linked Lists/Contest
LeetCode
- π‘ Minimum Operations to Make Array Equal Notes: take average
- π’ Three Consecutive Odds Notes: cakeWalk!
- π’ Reverse Linked List
Day 3
Focus for today: Linked Lists
LeetCode
- π’ Linked List Cycle Notes: unordered set or 2 pointers
- π’ Palindrome Linked List Notes: divide into 2 equal parts and use 2 pointers
AlgoExpert
- π΄ Merge Linked Lists Notes: π 3 pointers
Day 4
Focus for today: Trees
LeetCode
- π‘ Binary Tree Inorder Traversal Notes:π use stack
- π‘ Validate Binary Search Tree Notes: inorder has to be in sorted
- π‘ Kth Smallest Element in a BST Notes: think of inorder
- π’ Find Mode in Binary Search Tree Notes: think of preorder
AlgoExpert
- π‘ BST Construction Notes: π basics
Day 5
Focus for today: Trees
LeetCode
- π‘ Binary Tree Level Order Traversal Notes:π use queue
- π’ Convert Sorted Array to Binary Search Tree Notes: πbinary search
- π’ Maximum Depth of Binary Tree Notes: Either BFS/DFS
AlgoExpert
- π’ Find Closest Value in BST Notes: helper function
Day 6
Focus for today: Trees
LeetCode
- π’ Invert Binary Tree Notes: π queue/recursion
- π’ Thousand Seperator Notes: Brute-Force
- π’ Valid Parentheses Notes: use stack
Day 7
Focus for today: Contest
LeetCode
- π’ Most Visited Sector in a Circular Track Notes: circular => f = f%n
- π‘ Maximum Number of Coins You Can Get Notes: reverse and give you first
Day 8
Focus for today: Trees
LeetCode
- π‘ Check Completeness of a Binary Tree Notes: πuse flag
- π‘ Sum Root to Leaf Numbers Notes: recursion
- π’ Symmetric Tree Notes: recursion(best)
Day 9
Focus for today: Trees
LeetCode
- π‘ Path Sum II Notes: careful of callstack
- π’ Range Sum of BST Notes: Do any DFS - Cakewalk
Educative
Depth First Search Pattern
- π’ Binary Tree Path Sum
- π‘ All Paths for a Sum
- π‘ Sum of Path Numbers
Day 10
Focus for today: Trees
Educative
Depth First Search Pattern
- π‘ Path With Given Sequence
- π‘ Count Paths for a Sum Notes: πCareful of count in recursion
Day 11
Focus for today: Graphs
LeetCode
- π‘ Number of Connected Components in an Undirected Graph Notes: dfs pattern
- π‘ Number of Islands Notes: dfs in all 4 dirs
AlgoExpert
- π’ Depth First Search Notes: helper recursive function
Day 12
Focus for today: Algorithms
LeetCode
- π‘ Maximum Length of Subarray With Positive Product Notes: ππcareful of zeroes
- π’ Merge Two Binary Trees Notes: Update the Node, after every step for backtracking!
AlgoExpert
- π‘ Kadane's Algorithm Notes: used for finding maxSubArray
- π’ Nth Fibonacci Notes: Iterative method best among all!
Day 13
Focus for today: Everything
LeetCode
- π’ Majority Element Notes: Moore's Voting Algorithm
- π’ Valid Anagram Notes: take care of t.c and s.c
Day 14
Focus for today: Everything
LeetCode
- π’ Excel Sheet Column Number Notes: use map
- π’ First Unique Character in a String
Day 15
Focus for today: Everything
LeetCode
- π’ Repeated Substring Pattern Notes: make duplicate and ignore 1st and last
Day 16
Focus for today: Recursions, Contest
LeetCode
- π‘ Permutations Notes: π use backtracking
- π‘ Subsets Notes: backtracking
- π’ Matrix Diagonal Sum
- π‘ Subsets II Notes: backtraking
Day 17
Focus for today: Backtracking
LeetCode
- π‘ Combinations
- π‘ Combination Sum
- π‘ Combination Sum II
Day 18
Focus for today: Analysing Patterns
Educative
Sub Sets Pattern Notes: Follows BFS in every Approach
- π‘ String Permutation
- π‘ Playing With Permutations
- π‘ Combination of Subsets 2
- π’ Combination of Subset
Day 19
Focus for today: September Challenge
LeetCode
- π‘ Compare Version Numbers Notes: use istringstream and stoi stl
- π‘ Word Pattern Notes: use unordered maps
Day 20
Focus for today: Strings
AlgoExpert
- π’ Caesar Ciphor Encryptor
- π‘ Longest Palindromic Substring
Day 21
Focus for today: Strings
AlgoExpert
- π‘ Group Anagrams _Bucket Everything in hashmap and take care of TC and SC.
- π΄ Longest Substring Without Duplication
Day 22
Focus for today: Arrays
AlgoExpert
- π‘ Three Sum Notes: Take Care of Duplicates
- π‘ Smallest Difference Notes: Two Pointers
Day 23
Focus for today: Arrays
AlgoExpert
- π‘ Move Element To End Notes: Two Pointers
- π‘ Monotonic Array Notes: One Pass π₯
LeetCode
- π’ Monotonicity
Day 24
Focus for today: Contest, Miscellaneous
LeetCode
- π‘ XOR Queries of a Subarray Notes: xorSum vector and manupalate
- π’ Decrypt String from Alphabet to Integer Mapping Notes: general
Day 25
Focus for today: Interview Questions
LeetCode
- π’ Intersection of Two Arrays II Notes: set-intersection stl
- π’ Power of 3 Notes: log2(n) / log2(3)
- π’ Prime Numbers Notes: Sieve of eratosthenes
Day 26
- π‘ Spiral Traversal Notes: Make Sure of 4 variables and dir
- π‘ Longest Peak Notes: Binary Search
Day 27
- π’ Cyclic Rotate
- π’ Find the maximum and minimum element in an array
- π’ Find the "Kth" max and min element of an array
- π’ Move all the negative elements to one side of the array
Day 28
- π‘ Find duplicate in an array of N+1 Integers
- π‘ Find Largest sum contiguous Subarray
- π‘ Longest Consecutive Subsequence
- π‘ Merge Intervals
- π‘ Find maximum product subarray
- π‘ Smallest subarray with sum greater than a given value
Inspired by DeepakTalwar/interview-prep-cpp