This is a challenge by LeetCode consisting of 30 daily problems over the month of June. A problem is added each day, and we have 24 hours to make a valid submission. I will be uploading my solutions in this repository after the deadline to make a valid submission for the given problem has passed.
-
Day 1: Invert Binary Tree
Recursive Inversion | Time: O(n) | Space: O(n)
-
Day 2: Delete Node in a Linked List
Exchanging Node Data | Time: O(1) | Space: O(1)
-
Day 3: Two City Scheduling
Dynamic Programming | Time: O(n^2) | Space: O(n^2) (Recursive Stack)
-
Day 4: Inverse String
Swapping Characters | Time: O(n) | Space: O(1)
-
Day 5: Random Pick with Weight
Discrete Distribution + Binary Search | Time: O(n) (Precomputation) + O(logn) (Function Call) | Space: O(n)
-
Day 6: Queue Reconstruction by Height
Sorting | Time: O(n^2) | Space: O(n)
-
Day 7: Coin Change 2
Knapsack | Time: O(n*m) | Space: O(n)
-
Day 8: Power of Two
Bitwise Operation | Time: O(1) | Space: O(1)
-
Day 9: Is Subsequence
Recursive Character Matching | Time: O(n) | Space: O(n) (Recursive Stack)
-
Day 10: Search Insert Position
Binary Search | Time: O(log(n)) | Space: O(1)
-
Day 11: Sort Colors
Dutch National Flag Problem | Time: O(n) | Space: O(1)
-
Day 12: Insert Delete GetRandom O(1)
Map + Vector Data Structure | Time: O(1)[Average Complexity] | Space: O(n)
-
Day 13: Largest Divisible Subset
Dynamic Programming (LIS) | Time: O(n^2) | Space: O(n)
-
Day 14: Cheapest Flights Within K Stops
Dynamic Programming | Time: O(n*k) | Space: O((n^2)*k)
-
Day 15: Search In A Binary Search Tree
Recursive Binary Search | Time: O(log(n)) | Space: O(log(n))
-
Day 16: Validate IP Address
Tokenizing String | Time: O(n) | Space: O(n)
-
Day 17: Surrounded Regions
DFS | Time: O(n) | Space: O(n) (Where 'n' is the number of nodes)
-
Day 18: H-Index II
Binary Search | Time: O(log(n)) | Space: O(1)
-
Day 19: Longest Duplicate Substring
Binary Search + Rabin-Karp Algorithm | Time: O(n(log(n))) | Space: O(n)
-
Day 20: Permutation Sequence
Factorials | Time: O(n) | Space: O(n^2) (Recursive Stack + Map)
-
Day 21: Dungeon Game
Dynamic Programming | Time: O(n*m) | Space: O(n)
-
Day 22: Single Game II
Bitmasking | Time: O(n) | Space: O(1)
-
Day 23: Count Complete Tree Nodes
Recursive Traversal | Time: O(n) | Space: O(log(n))
-
Day 24: Unique Binary Search Trees
Catalan Number | Time: O(n) | Space: O(n)
-
Day 25: Find Duplicate Number
Floyd's Tortoise and Hare Algorithm | Time: O(n) | Space: O(1)
-
Day 26: Sum Root to Leaf Numbers
DFS | Time: O(n) | Space: O(n)
-
Day 27: Perfect Squares
Dynamic Programming | Time: O(n^3/2) | Space: O(n)
-
Day 28: Reconstruct Itinenary
Hierholzer Algorithm | Time: O(E) (Number of edges) | Space: O(E*E)
-
Day 29: Unique Paths
Dynamic Programming | Time: O(n*m) | Space: O(n)
-
Day 30: Word Search II
Trie + DFS | Time: O(n^2 * m * s) | Space: O(n^2 * m * s) (DFS Recursive Depth + Words Size)