Solutions to the LeetCode 30-day challenge in May 2020
Solutions will include only function stubs, unless otherwise mentioned.
Unless otherwise mentioned, n is the length of the array / string in consideration
Problem | Concepts/Algorithms Used | Complexity | Solution |
---|---|---|---|
1 | Binary Search | O(log n) | S01 |
2 | Substring, Sorting | O(n log n) | S02 |
3 | String Representation | O(n) | S03 |
4 | Bit Manipulation | O(b) (b -> Number of bits) | S04 |
5 | Hash Map | O(n) (Amortized, assuming unordered_map is O(1) |
S05 |
6 | Arrays, Voting Algorithms | O(n) | S06 |
7 | Binary Trees | O(n) (n -> Number of nodes) | S07 |
8 | Coordinate Geometry | O(n) (n -> Number of coordinates) | S08 |
9 | Binary Search | O(log n) | S09 |
10 | Arrays / Pairs / Hash Map | O(n) | S10 |
11 | Depth First Search (DFS) | O(n) | S11 |
12 | Arrays | O(n) | S12 |
13 | Strings, Number Theory | O(nk) (k -> Number of digits to remove) | S13 |
14 | Tries | O(nka) (n-> Number of strings, k -> Length of longest string, a -> Alphabet size) | S14 |
16 | Linked Lists | O(n) | S16 |
17 | Two Pointer, Hashing, Substring | O(n) | S17 |
18 | Sliding Window, Substring | O(n2) (n2 -> Length of larger string) | S18 |
19 | Stacks | O(n) | S19 |
20 | Binary Search Trees (BST) | O(n) (n -> Number of nodes) | S20 |
20 | Matrices | O(mn) | S21 |
22 | Strings, Dictionary/Hashing | O(n) | S22 |
23 | Arrays, Intervals | O(m + n) (m = A.length, n = B.length) | S23 |
24 | Binary Trees, BST | O(n) | S24 |