Leetcode hard problems and Solutions in C++/Java/Python
| # | Title | Solution | Time | Space | Tag |
|---|---|---|---|---|---|
| 1707 | Maximum XOR With an Element From Array | C++ | O(nlogn + mlogm + nlogk + mlogk) | O(nlogk) | bit-manipulation |
| 2151 | Maximum Good People Based on Statements | C++ | O(n^2 * 2^n) | O(1) | Bitmasks Brute Force |
| 1714 | Sum Of Special Evenly-Spaced Elements In Array | C++ | O(n * sqrt(n)) | O(n * sqrt(n)) | arrays |
| 1998 | GCD Sort of an Array | C++ | O(nlogn + m) | O(n + m) | Union Find Sieve of Eratosthenes |
| 1559 | Detect Cycles in 2D Grid | C++ | O(m * n) | O(m * n) | Union Find BFS |
| 1862 | Sum of Floored pairs | C++ | |||
| 2151 | Maximum Good People Based on Statements | C++ | O(n^2 * 2^n) | O(1) | Bitmasks Brute Force |
| 1714 | Sum Of Special Evenly-Spaced Elements In Array | C++ | O(n * sqrt(n)) | O(n * sqrt(n)) | arrays |
| 1998 | GCD Sort of an Array | C++ | O(nlogn + m) | O(n + m) | Union Find Sieve of Eratosthenes |
| 1970 | Last Day Where You Can Still Cross | C++ | O(m * n) | O(m * n) | Union Find |
| 1559 | Detect Cycles in 2D Grid | C++ | O(m * n) | O(m * n) | Union Find BFS |
| 2035 | Partition Array Into Two Arrays to Minimize Sum Difference | C++ | O(n * 2^n) | O(2^n) | Meet in the Middle |
| 1259 | Handshakes That Don't Cross | C++ | O(n) | O(1) | Catalan Number DP |
| 1012 | Numbers With Repeated Digits | C++ | O(n * 2^n) | O(2^n) | math |
| 2106 | Maximum Fruits Harvested After at Most K Steps | C++ | O(n) | O(n) | prefix-sum |
| 2122 | Recover the Original Array | C++ | O(n^2) | O(n) | |
| 2301 | Match Substring After Replacement | C++ | O(n^k) | O(m) | brute-force |