- R.I.P. to my old Leetcode repository, where there were
5.7k+
stars and2.2k+
forks (ever the top 3 in the field). - Since free questions may be even mistakenly taken down by some companies, only solutions will be post on now.
- There are new LeetCode questions every week. I'll keep updating for full summary and better solutions.
- For more problem solutions, you can see my LintCode, GoogleKickStart, GoogleCodeJamIO repositories.
- For more challenging problem solutions, you can also see my GoogleCodeJam, MetaHackerCup repositories.
- Hope you enjoy the journey of learning data structures and algorithms.
- Notes: "π" means your subscription of LeetCode premium membership is required for reading the question.
- Bit Manipulation
- Array
- String
- Linked List
- Stack
- Queue
- Binary Heap
- Tree
- Hash Table
- Math
- Sort
- Two Pointers
- Recursion
- Binary Search
- Binary Search Tree
- Breadth-First Search
- Depth-First Search
- Backtracking
- Dynamic Programming
- Greedy
- Graph
- Geometry
- Simulation
- Constructive Algorithms
- Design
- Concurrency
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
1310 | XOR Queries of a Subarray | C++ Python | O(n) | O(1) | Medium | ||
1318 | Minimum Flips to Make a OR b Equal to c | C++ Python | O(1) | O(1) | Medium | ||
1342 | Number of Steps to Reduce a Number to Zero | C++ Python | O(logn) | O(1) | Easy | ||
1558 | Minimum Numbers of Function Calls to Make Target Array | C++ Python | O(nlogn) | O(1) | Medium | Greedy | |
1707 | Maximum XOR With an Element From Array | C++ Python | O(nlogn + mlogm + nlogk + mlogk) | O(nlogk) | Hard | variant of Maximum XOR of Two Numbers in an Array | Greedy, Trie |
1720 | Decode XORed Array | C++ Python | O(n) | O(1) | Easy | ||
1734 | Decode XORed Permutation | C++ Python | O(n) | O(1) | Medium | ||
1829 | Maximum XOR for Each Query | C++ Python | O(n) | O(1) | Medium | ||
2151 | Maximum Good People Based on Statements | C++ Python | O(n^2 * 2^n) | O(1) | Hard | Bitmasks, Brute Force | |
2212 | Maximum Points in an Archery Competition | C++ Python | O(n * 2^n) | O(n) | Medium | Bitmasks, Brute Force | |
2220 | Minimum Bit Flips to Convert Number | C++ Python | O(logn) | O(1) | Easy | Bit Manipulation | |
2275 | Largest Combination With Bitwise AND Greater Than Zero | C++ Python | O(nlogr) | O(logr) | Medium | Bit Manipulation, Freq Table | |
2317 | Maximum XOR After Operations | C++ Python | O(n) | O(1) | Medium | Bit Manipulation, Greedy | |
2397 | Maximum Rows Covered by Columns | C++ Python | O(m * n + m * C(n, k)) | O(m) | Medium | Bitmasks, Hakmem Item 175 |
|
2411 | Smallest Subarrays With Maximum Bitwise OR | C++ Python | O(n) | O(1) | Medium | Bitmasks, Hash Table | |
2419 | Longest Subarray With Maximum Bitwise AND | C++ Python | O(n) | O(1) | Medium | Bit Manipulation | |
2425 | Bitwise XOR of All Pairings | C++ Python | O(n) | O(1) | Medium | Bit Manipulation | |
2429 | Minimize XOR | C++ Python | O(logn) | O(1) | Medium | Bit Manipulation, Greedy | |
2505 | Bitwise OR of All Subsequence Sums | C++ Python | O(n) | O(1) | Medium | π | Bit Manipulation |
2527 | Find Xor-Beauty of Array | C++ Python | O(n) | O(1) | Medium | Bit Manipulation, Math | |
2595 | Number of Even and Odd Bits | C++ Python | O(1) | O(1) | Easy | Bit Manipulation |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
1424 | Diagonal Traverse II | C++ Python | O(m * n) | O(m) | Medium | ||
1438 | Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit | C++ Python | O(n) | O(n) | Hard | Mono Deque | |
1499 | Max Value of Equation | C++ Python | O(n) | O(n) | Hard | Mono Deque | |
1696 | Jump Game VI | C++ Python | O(n) | O(k) | Medium | Mono Deque, Sliding Window | |
2398 | Maximum Number of Robots Within Budget | C++ Python | O(n) | O(n) | Hard | Mono Deque, Sliding Window, Two Pointers |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
1046 | Last Stone Weight | C++ Python | O(nlogn) | O(n) | Easy | ||
1057 | Campus Bikes | C++ Python | O((w * b) * log(w * b)) | O(w * b) | Medium | π | |
1439 | Find the Kth Smallest Sum of a Matrix With Sorted Rows | C++ Python | O(m * klogk) | O(k) | Hard | Binary Search | |
1606 | Find Servers That Handled Most Number of Requests | C++ Python | O(nlogk) | O(k) | Hard | Sorted List | |
1642 | Furthest Building You Can Reach | C++ Python | O(nlogk) | O(k) | Medium | ||
1675 | Minimize Deviation in Array | C++ Python | O((n * log(max_num)) * logn) | O(n) | Hard | ||
1792 | Maximum Average Pass Ratio | C++ Python | O(n + mlogn) | O(n) | Medium | ||
1882 | Process Tasks Using Servers | C++ Python | O(n + mlogn) | O(n) | Medium | ||
1962 | Remove Stones to Minimize the Total | C++ Python | O(n + klogn) | O(1) | Medium | ||
2054 | Two Best Non-Overlapping Events | C++ Python | O(nlogn) | O(n) | Medium | Line Sweep, Heap | |
2163 | Minimum Difference in Sums After Removal of Elements | C++ Python | O(nlogn) | O(n) | Hard | Heap, Prefix Sum | |
2208 | Minimum Operations to Halve Array Sum | C++ Python | O(nlogn) | O(n) | Medium | Heap | |
2386 | Find the K-Sum of an Array | C++ Python | O(nlogn + klogk) | O(n + k) | Hard | BFS, Heap | |
2402 | Meeting Rooms III | C++ Python | O(mlogm + n + mlogn) | O(n) | Hard | Heap | |
2462 | Total Cost to Hire K Workers | C++ Python | O(c + klogc) | O(c) | Medium | Heap, Two Pointers | |
2519 | Count the Number of K-Big Indices | C++ Python | O(nlogk) | O(n) | Hard | π | Heap, Ordered Set, Sorted List |
2530 | Maximal Score After Applying K Operations | C++ Python | O(n + klogn) | O(1) | Medium | Heap, Simulation | |
2558 | Take Gifts From the Richest Pile | C++ Python | O(n + klogn) | O(1) | Easy | Heap, Simulation |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
1054 | Distant Barcodes | C++ Python | O(n) | O(k) | Medium | variant of Rearrange String k Distance Apart | |
1086 | High Five | C++ Python | O(nlogn) | O(n) | Easy | π | |
1094 | Car Pooling | C++ Python | O(nlogn) | O(n) | Medium | variant of Meeting Rooms II | |
1122 | Relative Sort Array | C++ Python | O(nlogn) | O(n) | Easy | ||
1229 | Meeting Scheduler | C++ Python | O(nlogn) | O(n) | Medium | Line Sweep, Heap | |
1356 | Sort Integers by The Number of 1 Bits | C++ Python | O(nlogn) | O(1) | Easy | Bit Manipulation | |
1365 | How Many Numbers Are Smaller Than the Current Number | C++ Python | O(n + m) | O(m) | Easy | Counting Sort | |
1366 | Rank Teams by Votes | C++ Python | O(m * (n + mlogm)) | O(m^2) | Medium | ||
1451 | Rearrange Words in a Sentence | C++ Python | O(nlogn) | O(n) | Medium | String | |
1481 | Least Number of Unique Integers after K Removals | C++ Python | O(n) | O(n) | Medium | Counting Sort | |
1509 | Minimum Difference Between Largest and Smallest Value in Three Moves | C++ Python | O(n + klogk) | O(1) | Medium | Quick Select | |
1523 | Count Odd Numbers in an Interval Range | C++ Python | O(1) | O(1) | Easy | ||
1561 | Maximum Number of Coins You Can Get | C++ Python | O(nlogn) | O(1) | Medium | ||
1588 | Sum of All Odd Length Subarrays | C++ Python | O(n) | O(1) | Easy | ||
1608 | Special Array With X Elements Greater Than or Equal X | C++ Python | O(n) | O(1) | Easy | variant of H-Index | Counting Sort, Binary Search |
1620 | Coordinate With Maximum Network Quality | C++ Python | O(n^2) | O(1) | Medium | ||
1621 | Number of Sets of K Non-Overlapping Line Segments | C++ Python | O(1) | O(n) | Medium | Binomial Coefficients, Euler's Theorem |
|
1630 | Arithmetic Subarrays | C++ Python | O(n * q) | O(n) | Medium | Arithmetic Series | |
1636 | Sort Array by Increasing Frequency | C++ Python | O(nlogn) | O(n) | Easy | ||
1637 | Widest Vertical Area Between Two Points Containing No Points | C++ Python | O(nlogn) | O(n) | Medium | ||
1680 | Concatenation of Consecutive Binary Numbers | C++ Python | O(n) | O(1) | Medium | ||
1685 | Sum of Absolute Differences in a Sorted Array | C++ Python | O(n) | O(1) | Medium | ||
1688 | Count of Matches in Tournament | C++ Python | O(1) | O(1) | Easy | ||
1703 | Minimum Adjacent Swaps for K Consecutive Ones | C++ Python | O(n) | O(n) | Hard | Math, Median, Prefix Sum | |
1716 | Calculate Money in Leetcode Bank | C++ Python | O(1) | O(1) | Easy | Arithmetic Sequence | |
1772 | Sort Features by Popularity | C++ Python | O(n) | O(1) | Medium | π | |
1847 | Closest Room | C++ Python | O(nlogn + klogk + klogn) | O(n + k) | Hard | Sort, Binary Search | |
1851 | Minimum Interval to Include Each Query | C++ Python | O(nlogn + klogk + klogn) | O(n + k) | Hard | Sort, Heap, Line Sweep | |
1859 | Sorting the Sentence | C++ Python | O(n) | O(n) | Easy | Sort, String | |
1942 | The Number of the Smallest Unoccupied Chair | C++ Python | O(nlogn) | O(n) | Medium | Line Sweep, Heap | |
1943 | Describe the Painting | C++ Python | O(nlogn) | O(n) | Medium | Line Sweep | |
1968 | Array With Elements Not Equal to Average of Neighbors | C++ Python | O(n) on average | O(1) | Medium | variant of Wiggle Sort II | Quick Select, Tri Partition |
1985 | Find the Kth Largest Integer in the Array | C++ Python | O(n) on average | O(n) | Medium | Quick Select | |
1996 | The Number of Weak Characters in the Game | C++ Python | O(nlogn) | O(1) | Medium | ||
2015 | Average Height of Buildings in Each Segment | C++ Python | O(nlogn) | O(n) | Medium | π | Line Sweep |
2021 | Brightest Position on Street | C++ Python | O(nlogn) | O(n) | Medium | π | Line Sweep |
2070 | Most Beautiful Item for Each Query | C++ Python | O(nlogn + qlogn) | O(1) | Medium | Sort, Binary Search | |
2089 | Find Target Indices After Sorting Array | C++ Python | O(n) | O(1) | Easy | Counting Sort | |
2158 | Amount of New Area Painted Each Day | C++ Python | O(nlogr) | O(r) | Hard | π | Line Sweep, Sorted List, Heap, Segment Tree |
2164 | Sort Even and Odd Indices Independently | C++ Python | O(n) | O(c) | Easy | Counting Sort, Inplace | |
2191 | Sort the Jumbled Numbers | C++ Python | O(nlogm + nlogn) | O(n) | Medium | Sort | |
2231 | Largest Number After Digit Swaps by Parity | C++ Python | O(logn) | O(1) | Easy | Counting Sort | |
2233 | Maximum Product After K Increments | C++ Python | O(n + k) | O(n) | Medium | Heap, Freq Table, Sort, Math | |
2248 | Intersection of Multiple Arrays | C++ Python | O(n * l + r) | O(l) | Easy | Hash Table, Counting Sort | |
2251 | Number of Flowers in Full Bloom | C++ Python | O(nlogn + mlogn) | O(n) | Hard | Line Sweep, Binary Search | |
2343 | Query Kth Smallest Trimmed Number | C++ Python | O(q + n * t) | O(t + n + q) | Medium | Sort, Quick Select, Radix Sort | |
2418 | Sort the People | C++ Python | O(nlogn) | O(n) | Easy | Sort | |
2497 | Maximum Star Sum of a Graph | C++ Python | O(n) | O(n) | Medium | Sort, Quick Select | |
2512 | Reward Top K Students | C++ Python | O(pf * l + nf * l + n * l + klogk) | O(pf * l + nf * l + n) | Medium | Partial Sort, Quick Select | |
2545 | Sort the Students by Their Kth Score | C++ Python | O(mlogm) | O(1) | Medium | Sort | |
2659 | Make Array Empty | C++ Python | O(nlogn) | O(n) | Hard | Sort, BIT, Fenwick Tree |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
1004 | Max Consecutive Ones III | C++ Python | O(n) | O(1) | Medium | Sliding Window | |
1033 | Moving Stones Until Consecutive | C++ Python | O(1) | O(1) | Easy | ||
1040 | Moving Stones Until Consecutive II | C++ Python | O(nlogn) | O(1) | Medium | ||
1151 | Minimum Swaps to Group All 1's Together | C++ Python | O(n) | O(1) | Medium | π | Sliding Window |
1156 | Swap For Longest Repeated Character Substring | C++ Python | O(n) | O(1) | Medium | Sliding Window | |
1176 | Diet Plan Performance | C++ Python | O(n) | O(1) | Easy | Sliding Window | |
1208 | Get Equal Substrings Within Budget | C++ Python | O(n) | O(1) | Medium | Sliding Window | |
1213 | Intersection of Three Sorted Arrays | C++ Python | O(n) | O(1) | Easy | π | |
1169 | Invalid Transactions | C++ Python | O(nlogn) | O(n) | Medium | Sliding Window, Line Sweep | |
1214 | Two Sum BSTs | C++ Python | O(n) | O(n) | Medium | π | Stack |
1234 | Replace the Substring for Balanced String | C++ Python | O(n) | O(t) | Medium | Two Pointers, Sliding Window | |
1248 | Count Number of Nice Subarrays | C++ Python | O(n) | O(k) | Medium | variant of Subarrays with K Different Integers | Two Pointers, Sliding Window |
1297 | Maximum Number of Occurrences of a Substring | C++ Python | O(n) | O(n) | Medium | Sliding Window, Rabin-Karp Algorithm |
|
1305 | All Elements in Two Binary Search Trees | C++ Python | O(n) | O(h) | Medium | Stack | |
1316 | Distinct Echo Substrings | C++ Python | O(n^2 + d) | O(r) | Hard | KMP Algorithm , Sliding Window, Rabin-Karp Algorithm |
|
1358 | Number of Substrings Containing All Three Characters | C++ Python | O(n) | O(1) | Medium | Sliding Window | |
1423 | Maximum Points You Can Obtain from Cards | C++ Python | O(n) | O(1) | Medium | Sliding Window | |
1425 | Constrained Subset Sum | C++ Python | O(n) | O(k) | Hard | variant of Sliding Window Maximum | Mono Deque, Sliding Window |
1456 | Maximum Number of Vowels in a Substring of Given Length | C++ Python | O(n) | O(1) | Medium | Sliding Window | |
1493 | Longest Subarray of 1's After Deleting One Element | C++ Python | O(n) | O(1) | Medium | Sliding Window | |
1498 | Number of Subsequences That Satisfy the Given Sum Condition | C++ Python | O(nlogn) | O(n) | Medium | Two Pointers | |
1508 | Range Sum of Sorted Subarray Sums | C++ Python | O(nlog(sum(nums))) | O(n) | Medium | Binary Search, Two Pointers, Sliding Window | |
1521 | Find a Value of a Mysterious Function Closest to Target | C++ Python | O(nlogm) | O(logm) | Hard | DP, Two Pointers, Sliding Window | |
1604 | Alert Using Same Key-Card Three or More Times in a One Hour Period | C++ Python | O(nlogn) | O(n) | Medium | Two Pointers, Sliding Window | |
1658 | Minimum Operations to Reduce X to Zero | C++ Python | O(n) | O(1) | Medium | Two Pointers | |
1687 | Delivering Boxes from Storage to Ports | C++ Python | O(nlogn) | O(n) | Hard | Two Pointers, Sliding Window | |
1695 | Maximum Erasure Value | C++ Python | O(n) | O(n) | Medium | Two Pointers, Sliding Window | |
1712 | Ways to Split Array Into Three Subarrays | C++ Python | O(n) | O(n) | Medium | Two Pointers, Prefix Sum | |
1750 | Minimum Length of String After Deleting Similar Ends | C++ Python | O(n) | O(1) | Medium | Two Pointers | |
1838 | Frequency of the Most Frequent Element | C++ Python | O(nlogn) | O(n) | Medium | Two Pointers, Sliding Window | |
1852 | Distinct Numbers in Each Subarray | C++ Python | O(n) | O(k) | Medium | π | Two Pointers, Sliding Window |
1855 | Maximum Distance Between a Pair of Values | C++ Python | O(n + m) | O(1) | Medium | Two Pointers | |
1868 | Product of Two Run-Length Encoded Arrays | C++ Python | O(m + n) | O(1) | Medium | π | Two Pointers |
1885 | Count Pairs in Two Arrays | C++ Python | O(nlogn) | O(1) | Medium | π | Two Pointers |
1888 | Minimum Number of Flips to Make the Binary String Alternatings | C++ Python | O(n) | O(1) | Medium | Two Pointers, Sliding Window | |
1984 | Minimum Difference Between Highest and Lowest of K Scores | C++ Python | O(nlogn) | O(1) | Easy | Two Pointers, Sliding Window | |
1989 | Maximum Number of People That Can Be Caught in Tag | C++ Python | O(n) | O(1) | Medium | π | Greedy, Two Pointers, Sliding Window |
2009 | Minimum Number of Operations to Make Array Continuous | C++ Python | O(nlogn) | O(1) | Hard | Two Pointers, Sliding Window | |
2024 | Maximize the Confusion of an Exam | C++ Python | O(n) | O(1) | Medium | variant of Longest Repeating Character Replacement | Sliding Window |
2040 | Kth Smallest Product of Two Sorted Arrays | C++ Python | O((m + n) * logr) | O(1) | Hard | Binary Search, Two Pointers | |
2046 | Sort Linked List Already Sorted Using Absolute Values | C++ Python | O(n) | O(1) | Medium | π | Linked List |
2062 | Count Vowel Substrings of a String | C++ Python | O(n) | O(1) | Easy | variant of Count Number of Nice Subarrays | Sliding Window |
2067 | Number of Equal Count Substrings | C++ Python | O(n) | O(1) | Medium | π | Sliding Window |
2090 | K Radius Subarray Averages | C++ Python | O(n) | O(1) | Medium | Sliding Window | |
2105 | Watering Plants II | C++ Python | O(n) | O(1) | Medium | Simulation | |
2107 | Number of Unique Flavors After Sharing K Candies | C++ Python | O(n) | O(n) | Medium | π | Sliding Window |
2134 | Minimum Swaps to Group All 1's Together II | C++ Python | O(n) | O(1) | Medium | Sliding Window | |
2149 | Rearrange Array Elements by Sign | C++ Python | O(n) | O(1) | Medium | Two Pointers | |
2161 | Partition Array According to Given Pivot | C++ Python | O(n) | O(n) | Medium | Two Pointers | |
2200 | Find All K-Distant Indices in an Array | C++ Python | O(n) | O(1) | Easy | Two Pointers | |
2234 | Maximum Total Beauty of the Gardens | C++ Python | O(nlogn) | O(1) | Hard | Sort, Prefix Sum, Greedy, Binary Search, Two Pointers | |
2302 | Count Subarrays With Score Less Than K | C++ Python | O(n) | O(1) | Hard | Two Pointers, Sliding Window | |
2330 | Valid Palindrome IV | C++ Python | O(n) | O(1) | Medium | π | String, Two Pointers |
2332 | The Latest Time to Catch a Bus | C++ Python | O(nlogn + mlogm) | O(1) | Medium | String, Two Pointers | |
2337 | Move Pieces to Obtain a String | C++ Python | O(n + m) | O(1) | Medium | String, Two Pointers | |
2348 | Number of Zero-Filled Subarrays | C++ Python | O(n) | O(1) | Medium | Two Pointers, Combinatorics | |
2379 | Minimum Recolors to Get K Consecutive Black Blocks | C++ Python | O(n) | O(1) | Easy | Sliding Window | |
2393 | Count Strictly Increasing Subarrays | C++ Python | O(n) | O(1) | Medium | π | Two Pointers |
2401 | Longest Nice Subarray | C++ Python | O(n) | O(1) | Medium | Sliding Window, Two Pointers | |
2444 | Count Subarrays With Fixed Bounds | C++ Python | O(n) | O(1) | Hard | variant of Number of Substrings Containing All Three Characters | Two Pointers |
2461 | Maximum Sum of Distinct Subarrays With Length K | C++ Python | O(n) | O(k) | Medium | Two Pointers | |
2465 | Number of Distinct Averages | C++ Python | O(nlogn) | O(n) | Easy | Two Pointers, Hash Table | |
2511 | Maximum Enemy Forts That Can Be Captured | C++ Python | O(n) | O(1) | Easy | Array, Two Pointers | |
2516 | Take K of Each Character From Left and Right | C++ Python | O(n) | O(1) | Medium | Sliding Window, Two Pointers | |
2524 | Maximum Frequency Score of a Subarray | C++ Python | O(n) | O(n) | Hard | π | Sliding Window, Two Pointers, Freq Table, Hash Table |
2537 | Count the Number of Good Subarrays | C++ Python | O(n) | O(n) | Medium | Sliding Window, Two Pointers | |
2540 | Minimum Common Value | C++ Python | O(n) | O(1) | Easy | Two Pointers | |
2555 | Maximize Win From Two Segments | C++ Python | O(n) | O(n) | Medium | Two Pointers, Sliding Window, DP | |
2563 | Count the Number of Fair Pairs | C++ Python | O(nlogn) | O(1) | Medium | Sort, Two Pointers | |
2570 | Merge Two 2D Arrays by Summing Values | C++ Python | O(n) | O(1) | Easy | Two Pointers | |
2609 | Find the Longest Balanced Substring of a Binary String | C++ Python | O(n) | O(1) | Easy | String, Two Pointers | |
2653 | Sliding Subarray Beauty | C++ Python | O(nlogk) | O(k) | Medium | Sorted List, Ordered Set, Two Pointers |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
1106 | Parsing A Boolean Expression | C++ Python | O(n) | O(n) | Hard | ||
2613 | Beautiful Pairs | C++ Python | O(n) on average | O(n) | Hard | π, variant of SPOJ - Closest Point Pair | Random Algorithms, Divide and Conquer, Merge Sort, Segment Tree |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
1373 | Maximum Sum BST in Binary Tree | C++ Python | O(n) | O(h) | Hard | DFS, Stack | |
1382 | Balance a Binary Search Tree | C++ Python | O(n) | O(h) | Medium | DFS, Stack | |
1902 | Depth of BST Given Insertion Order | C++ Python | O(nlogn) | O(n) | Medium | π | Sorted Dict |
1932 | Merge BSTs to Create Single BST | C++ Python | O(n) | O(n) | Hard | BST, BFS | |
2426 | Number of Pairs Satisfying Inequality | C++ Python | O(nlogn) | O(n) | Hard | Merge Sort, Two Pointers, BIT, Fenwick Tree, Coordinate Compression, Sorted List, Ordered Set, Binary Search |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
1034 | Coloring A Border | C++ Python | O(m * n) | O(m + n) | Medium | ||
1036 | Escape a Large Maze | C++ Python | O(n^2) | O(n) | Hard | ||
1091 | Shortest Path in Binary Matrix | C++ Python | O(n^2) | O(n) | Medium | ||
1102 | Path With Maximum Minimum Value | C++ Python | O((m * n) * log(m * n)) | O(m * n) | Medium | π | Binary Search, DFS, Dijkstra's Algorithm |
1129 | Shortest Path with Alternating Colors | C++ Python | O(n + e) | O(n + e) | Medium | ||
1136 | Parallel Courses | C++ Python | O(|V| + |E|) | O(|E|) | Hard | π | Topological Sort |
1161 | Maximum Level Sum of a Binary Tree | C++ Python | O(n) | O(w) | Medium | DFS | |
1162 | As Far from Land as Possible | C++ Python | O(m * n) | O(m * n) | Medium | ||
1203 | Sort Items by Groups Respecting Dependencies | C++ Python | O(n + e) | O(n + e) | Hard | Topological Sort | |
1210 | Minimum Moves to Reach Target with Rotations | C++ Python | O(n) | O(n) | Hard | ||
1215 | Stepping Numbers | C++ Python | O(logk + r) | O(k) | Medium | π | Precompute, Binary Search |
1245 | Tree Diameter | C++ Python | O(|V| + |E|) | O(|E|) | Medium | ||
1263 | Minimum Moves to Move a Box to Their Target Location | C++ Python | O(m^2 * n^2) | O(m^2 * n^2) | Hard | A* Search Algorithm |
|
1284 | Minimum Number of Flips to Convert Binary Matrix to Zero Matrix | C++ Python | O((m * n) * 2^(m * n)) | O((m * n) * 2^(m * n)) | Hard | ||
1291 | Sequential Digits | C++ Python | O(1) | O(1) | Medium | ||
1293 | Shortest Path in a Grid with Obstacles Elimination | C++ Python | O(m * n * k) | O(m * n) | Hard | A* Search Algorithm |
|
1298 | Maximum Candies You Can Get from Boxes | C++ Python | O(n^2) | O(n) | Hard | ||
1302 | Deepest Leaves Sum | C++ Python | O(n) | O(w) | Medium | ||
1306 | Jump Game III | C++ Python | O(n) | O(n) | Medium | ||
1311 | Get Watched Videos by Your Friends | C++ Python | O(n + vlogv) | O(w) | Medium | ||
1345 | Jump Game IV | C++ Python | O(n) | O(n) | Hard | ||
1368 | Minimum Cost to Make at Least One Valid Path in a Grid | C++ Python | O(m * n) | O(m * n) | Hard | A* Search Algorithm , 0-1 BFS, Deque |
|
1514 | Path with Maximum Probability | C++ Python | O(|E| * log|V|) | O(|E|) | Medium | Dijkstra's Algorithm |
|
1602 | Find Nearest Right Node in Binary Tree | C++ Python | O(n) | O(w) | Medium | π | |
1609 | Even Odd Tree | C++ Python | O(n) | O(w) | Medium | ||
1625 | Lexicographically Smallest String After Applying Operations | C++ Python | O(n^2) | O(1) | Medium | BFS, String | |
1654 | Minimum Jumps to Reach Home | C++ Python | O(max(x, max(forbidden)) + a + b) | O(max(x, max(forbidden)) + a + b) | Medium | BFS | |
1660 | Correct a Binary Tree | C++ Python | O(n) | O(w) | Medium | π | BFS |
1728 | Cat and Mouse II | C++ Python | O((m * n)^2 * (m + n)) | O((m * n)^2) | Hard | variant of Cat and Mouse | MiniMax, Topological Sort |
1730 | Shortest Path to Get Food | C++ Python | O(m * n) | O(m + n) | Medium | π | BFS |
1765 | Map of Highest Peak | C++ Python | O(m * n) | O(m * n) | Medium | BFS | |
1926 | Nearest Exit from Entrance in Maze | C++ Python | O(m * n) | O(m + n) | Medium | Bi-BFS | |
1928 | Minimum Cost to Reach Destination in Time | C++ Python | O(|E| * log|V|) | O(|E|) | Hard | variant of Cheapest Flights Within K Stops | Dijkstra's Algorithm |
2039 | The Time When the Network Becomes Idle | C++ Python | O(|E|) | O(|E|) | Medium | Math | |
2045 | Second Minimum Time to Reach Destination | C++ Python | O(|E|) | O(|E|) | Hard | Bi-BFS | |
2050 | Parallel Courses III | C++ Python | O(|V| + |E|) | O(|E|) | Hard | variant of Parallel Courses | Topological Sort |
2059 | Minimum Operations to Convert Number | C++ Python | O(m * n) | O(m) | Medium | ||
2115 | Find All Possible Recipes from Given Supplies | C++ Python | O(|E|) | O(|E|) | Medium | Topological Sort | |
2146 | K Highest Ranked Items Within a Price Range | C++ Python | O(m * n + klogk) | O(m * n) | Medium | BFS, Quick Select, Sort | |
2258 | Escape the Spreading Fire | C++ Python | O(m * n) | O(m * n) | Hard | BFS | |
2290 | Minimum Obstacle Removal to Reach Corner | C++ Python | O(m * n) | O(m * n) | Hard | variant of Minimum Cost to Make at Least One Valid Path in a Grid | A* Search Algorithm , 0-1 BFS, Deque |
2316 | Count Unreachable Pairs of Nodes in an Undirected Graph | C++ Python | O(n) | O(n) | Medium | Flood Fill, BFS, Math | |
2368 | Reachable Nodes With Restrictions | C++ Python | O(n) | O(n) | Medium | BFS | |
2415 | Reverse Odd Levels of Binary Tree | C++ Python | O(n) | O(n) | Medium | BFS | |
2471 | Minimum Number of Operations to Sort a Binary Tree by Level | C++ Python | O(nlogn) | O(w) | Medium | Sort, BFS | |
2492 | Minimum Score of a Path Between Two Cities | C++ Python | O(n + m) | O(n + m) | Medium | BFS | |
2493 | Divide Nodes Into the Maximum Number of Groups | C++ Python | O(n^2) | O(n) | Medium | variant of Is Graph Bipartite? | BFS, DFS |
2503 | Maximum Number of Points From Grid Queries | C++ Python | O((m * n + q) * log(m * n)) | O(m * n) | Hard | BFS, Heap, Prefix Sum, Binary Search | |
2577 | Minimum Time to Visit a Cell In a Grid | C++ Python | O(m * n * log(m * n)) | O(m * n) | Hard | Dijkstra's Algorithm |
|
2583 | Kth Largest Sum in a Binary Tree | C++ Python | O(n) | O(n) | Medium | BFS, Quick Select | |
2603 | Collect Coins in a Tree | C++ Python | O(n) | O(n) | Hard | Tree, BFS | |
2612 | Minimum Reverse Operations | C++ Python | O(n) | O(n) | Hard | BFS, Union Find, BST, Sorted List | |
2617 | Minimum Number of Visited Cells in a Grid | C++ Python | O(m * n) | O(m * n) | Hard | variant of Minimum Reverse Operations | BFS, Union Find, BST, Sorted List |
2641 | Cousins in Binary Tree II | C++ Python | O(n) | O(w) | Medium | BFS | |
2658 | Maximum Number of Fish in a Grid | C++ Python | O(m * n) | O(m + n) | Medium | BFS, DFS |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
1087 | Brace Expansion | C++ Python | O(p * l * log(p * l)) | O(p * l) | Medium | π | |
1096 | Brace Expansion II | C++ Python | O(p * l * log(p * l)) | O(p * l) | Hard | ||
1219 | Path with Maximum Gold | C++ Python | O(m^2 * n^2) | O(m * n) | Medium | ||
1240 | Tiling a Rectangle with the Fewest Squares | C++ Python | O(n^2 * m^2 * m^(n * m)) | O(n * m) | Hard | ||
1255 | Maximum Score Words Formed by Letters | C++ Python | O(n * 2^n) | O(n) | Hard | ||
1258 | Synonymous Sentences | C++ Python | O(p * l * log(p * l)) | O(p * l) | Medium | Union Find | |
1307 | Verbal Arithmetic Puzzle | C++ Python | O(10! * n * l) | O(n * l) | Hard | ||
1379 | Find a Corresponding Node of a Binary Tree in a Clone of That Tree | C++ Python | O(n) | O(h) | Medium | Stack | |
1593 | Split a String Into the Max Number of Unique Substrings | C++ Python | O(n * 2^(n - 1)) | O(n) | Medium | ||
1659 | Maximize Grid Happiness | C++ Python | O(C(m * n, i) * C(m * n - i, e)) | O(min(m * n, i + e)) | Hard | Pruning | |
1718 | Construct the Lexicographically Largest Valid Sequence | C++ Python | O(n!) | O(b) | Medium | Backtracking | |
1723 | Find Minimum Time to Finish All Jobs | C++ Python | O(k^n * logr) | O(n + k) | Hard | Backtracking, Pruning, Binary Search | |
1849 | Splitting a String Into Descending Consecutive Values | C++ Python | O(n^2) | O(n) | Medium | ||
1999 | Smallest Greater Multiple Made of Two Digits | C++ Python | O(1) | O(1) | Medium | π | Backtracking, Bit Manipulation |
2014 | Longest Subsequence Repeated k Times | C++ Python | O(n * (n/k)!) | O(n/k) | Hard | ||
2056 | Number of Valid Move Combinations On Chessboard | C++ Python | O(1) | O(1) | Hard | ||
2094 | Finding 3-Digit Even Numbers | C++ Python | O(n) | O(1) | Easy | ||
2443 | Sum of Number and Its Reverse | C++ Python | O(n^(1/(2*log2(10)))) | O(log10(n)/2) | Medium | Brute Force, Backtracking |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
1042 | Flower Planting With No Adjacent | C++ Python | O(n) | O(n) | Easy | ||
1101 | The Earliest Moment When Everyone Become Friends | C++ Python | O(nlogn) | O(n) | Medium | π | Union Find |
1135 | Connecting Cities With Minimum Cost | C++ Python | O(nlogn) | O(n) | Medium | π | Union Find, Kruskal's Algorithm , MST |
1168 | Optimize Water Distribution in a Village | C++ Python | O(nlogn) | O(n) | Hard | π | Union Find |
1334 | Find the City With the Smallest Number of Neighbors at a Threshold Distance | C++ Python | O(n^3) | O(n^2) | Medium | Floyd-Warshall Algorithm |
|
1349 | Maximum Students Taking Exam | C++ Python | O(m * n * sqrt(m * n)) | O(m + n) | Hard | GCJ2008 - Round 3 | Hopcroft-Karp Bipartite Matching , Hungarian Bipartite Matching , Maximum Independent Set |
1361 | Validate Binary Tree Nodes | C++ Python | O(n) | O(n) | Medium | DFS, Tree | |
1462 | Course Schedule IV | C++ Python | O(n^3) | O(n^2) | Medium | Floyd-Warshall Algorithm |
|
1489 | Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree | C++ Python | O(nlogn) | O(n) | Hard | Kruskal Algorithm |
|
1557 | Minimum Number of Vertices to Reach All Nodes | C++ Python | O(e) | O(n) | Medium | ||
1579 | Remove Max Number of Edges to Keep Graph Fully Traversable | C++ Python | O(n + m) | O(n) | Hard | Union Find | |
1584 | Min Cost to Connect All Points | C++ Python | O(n^2) | O(n) | Medium | Union Find, Kruskal's Algorithm , MST |
|
1601 | Maximum Number of Achievable Transfer Requests | C++ Python | O((n + r) * 2^r) | O(n + r) | Hard | Combinations, Backtracking | |
1615 | Maximal Network Rank | C++ Python | O(m + n + k^2) | O(m + n) | Medium | Counting Sort | |
1627 | Graph Connectivity With Threshold | C++ Python | O(nlogn + q) | O(n) | Hard | Union Find, Math | |
1631 | Path With Minimum Effort | C++ Python | O(m * n * log(m * n)) | O(m * n) | Medium | Binary Search, DFS, BFS, Bi-BFS, Union Find, Dijkstra's Algorithm |
|
1697 | Checking Existence of Edge Length Limited Paths | C++ Python | O(nlogn + mlogm) | O(n) | Hard | Union Find | |
1719 | Number Of Ways To Reconstruct A Tree | C++ Python | O(nlogn) | O(n) | Hard | ||
1724 | Checking Existence of Edge Length Limited Paths II | C++ Python | ctor: O(nlogn + mlogm) query: O(logn) |
O(nlogn + m) | Hard | π | Versioned Union Find, Binary Lifting |
1743 | Restore the Array From Adjacent Pairs | C++ Python | O(n) | O(n) | Medium | ||
1761 | Minimum Degree of a Connected Trio in a Graph | C++ Python | O(n^3) | O(n^2) | Hard | ||
1778 | Shortest Path in a Hidden Grid | C++ Python | O(m * n) | O(m * n) | Medium | π | DFS, BFS, Bi-BFS |
1782 | Count Pairs Of Nodes | C++ Python | O(n + e + q) | O(n + e) | Hard | Counting, Two Pointers | |
1786 | Number of Restricted Paths From First to Last Node | C++ Python | O(|E| * log|V|) | O(|E|) | Medium | Dijkstra's Algorithm , DP |
|
1791 | Find Center of Star Graph | C++ Python | O(n) | O(n) | Medium | ||
1810 | Minimum Path Cost in a Hidden Grid | C++ Python | O(m * n * log(m * n)) | O(m * n) | Medium | π | DFS, Dijkstra's Algorithm |
1820 | Maximum Number of Accepted Invitations | C++ Python | O(m * n * sqrt(m + n)) | O(m + n) | Medium | π | Hopcroft-Karp Bipartite Matching , Hungarian Bipartite Matching |
1879 | Minimum XOR Sum of Two Arrays | C++ Python | O(n^3) | O(n^2) | Hard | DP, Hungarian Weighted Bipartite Matching |
|
1947 | Maximum Compatibility Score Sum | C++ Python | O(m^2 * (n + m)) | O(m^2) | Medium | variant of Minimum XOR Sum of Two Arrays | DP, Hungarian Weighted Bipartite Matching |
1971 | Find if Path Exists in Graph | C++ Python | O(|V| + |E|) | O(|V| + |E|) | Easy | DFS, BFS, Bi-BFS | |
1976 | Number of Ways to Arrive at Destination | C++ Python | O(|E| * log|V|) | O(|E|) | Medium | Dijkstra's Algorithm |
|
2076 | Process Restricted Friend Requests | C++ Python | O(n * r) | O(n) | Hard | Union Find | |
2077 | Paths in Maze That Lead to Same Room | C++ Python | O(|V|^3) | O(|E|) | Medium | π | |
2092 | Find All People With Secret | C++ Python | O(nlogn) | O(nlogn) | Hard | BFS, DFS, Union Find | |
2093 | Minimum Path Cost in a Hidden Grid | C++ Python | O(|E| * log|V|) | O(|V| + |E|) | Medium | variant of Cheapest Flights Within K Stops, π | Dijkstra's Algorithm , DP |
2097 | Valid Arrangement of Pairs | C++ Python | O(|V| + |E|) | O(|V| + |E|) | Hard | variant of Reconstruct Itinerary | Hierholzer's Algorithm , Eulerian Path |
2123 | Minimum Operations to Remove Adjacent Ones in Matrix | C++ Python | O(m * n * sqrt(m * n)) | O(m + n) | Hard | variant of Maximum Students Taking Exam, π | Hopcroft-Karp Bipartite Matching , Maximum Independent Set |
2127 | Maximum Employees to Be Invited to a Meeting | C++ Python | O(n) | O(n) | Hard | ||
2172 | Maximum AND Sum of Array | C++ Python | O(n^3) | O(n^2) | Hard | variant of Maximum Compatibility Score Sum | DP, Hungarian Weighted Bipartite Matching |
2203 | Minimum Weighted Subgraph With the Required Paths | C++ Python | O(|E| * log|V|) | O(|E|) | Hard | Dijkstra's Algorithm |
|
2204 | Distance to a Cycle in Undirected Graph | C++ Python | O(|V| + |E|) | O(|V| + |E|) | Hard | π | Graph, DFS, BFS |
2242 | Maximum Score of a Node Sequence | C++ Python | O(|V| + |E|) | O(|V|) | Hard | Graph | |
2307 | Check for Contradictions in Equations | C++ Python | O(e + q) | O(n) | Hard | π, variant of Evaluate Division | DFS, Union Find |
2359 | Find Closest Node to Given Two Nodes | C++ Python | O(n) | O(n) | Medium | Graph, Hash Table, DFS | |
2360 | Longest Cycle in a Graph | C++ Python | O(n) | O(n) | Hard | Graph, Hash Table, DFS | |
2392 | Build a Matrix With Conditions | C++ Python | O(k^2 + r + c) | O(k + r + c) | Hard | Graph, Topological Sort | |
2473 | Minimum Cost to Buy Apples | C++ Python | O(n * rlogn) | O(n) | Medium | π | Dijkstra's Algorithm |
2508 | Add Edges to Make Degrees of All Nodes Even | C++ Python | O(n) | O(n) | Hard | Graph | |
2608 | Shortest Cycle in a Graph | C++ Python | O(n^2) | O(n + e) | Hard | Graph, BFS | |
2662 | Minimum Cost of a Path With Special Roads | C++ Python | O(n^2) | O(n^2) | Medium | Graph, Dijkstra's Algorithm |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
1453 | Maximum Number of Darts Inside of a Circular Dartboard | C++ Python | O(n^2 * logn) | O(n) | Hard | Line Sweep | |
1515 | Best Position for a Service Centre | C++ Python | O(n * iter) | O(n) | Hard | Geometric Median, Gradient Descent, Weiszfeld's Algorithm | |
1610 | Maximum Number of Visible Points | C++ Python | O(nlogn) | O(n) | Hard | Two Pointers, Sliding Window | |
1924 | Erect the Fence II | C++ Python | O(n) on average | O(n) | Hard | π | Welzl's Algorithm |
1956 | Minimum Time For K Virus Variants to Spread | C++ Python | O(nlogn * logr) | O(n) | Hard | π | Geometry, Binary Search, Line Sweep, Segment Tree, Coordinate Compression |
2101 | Detonate the Maximum Bombs | C++ Python | O(|V|^2 + \V| * |E|) | O(\V| + |E|) | Medium | Graph, DFS, BFS |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
1138 | Alphabet Board Path | C++ Python | O(n) | O(1) | Medium | ||
1243 | Array Transformation | C++ Python | O(n^2) | O(n) | Easy | ||
2061 | Number of Spaces Cleaning Robot Cleaned | C++ Python | O(m * n) | O(1) | Medium | π | |
2162 | Minimum Cost to Set Cooking Time | C++ Python | O(1) | O(1) | Medium | ||
2257 | Count Unguarded Cells in the Grid | C++ Python | O(m * n) | O(m * n) | Medium | Array, Simulation | |
2303 | Calculate Amount Paid in Taxes | C++ Python | O(n) | O(1) | Easy | Simulation | |
2507 | Smallest Value After Replacing With Sum of Prime Factors | C++ Python | O(s * logn) | O(max_n^0.5) | Medium | Number Theory, Simulation | |
2532 | Time to Cross a Bridge | C++ Python | O(k + nlogk) | O(k) | Hard | Heap, Simulation | |
2534 | Time Taken to Cross the Door | C++ Python | O(n) | O(n) | Hard | π | Queue, Simulation |
2593 | Find Score of an Array After Marking All Elements | C++ Python | O(nlogn) | O(n) | Medium | Simulation, Sort, Hash Table | |
2596 | Check Knight Tour Configuration | C++ Python | O(m * n) | O(m * n) | Medium | Simulation, Hash Table |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
2202 | Maximize the Topmost Element After K Moves | C++ Python | O(min(n, k)) | O(1) | Medium | Constructive Algorithms | |
2335 | Minimum Amount of Time to Fill Cups | C++ Python | O(1) | O(1) | Easy | Math, Constructive Algorithms | |
2350 | Shortest Impossible Sequence of Rolls | C++ Python | O(n) | O(k) | Hard | Constructive Algorithms | |
2546 | Apply Bitwise Operations to Make Strings Equal | C++ Python | O(n) | O(1) | Medium | Constructive Algorithms | |
2358 | Maximum Number of Groups Entering a Competition | C++ Python | O(1) | O(1) | Medium | Constructive Algorithms, Math | |
2610 | Convert an Array Into a 2D Array With Conditions | C++ Python | O(n) | O(n) | Medium | Freq Table, Constructive Algorithms | |
2647 | Color the Triangle Red | C++ Python | O(n^2) | O(1) | Hard | π | Constructive Algorithms |
2654 | Minimum Number of Operations to Make All Array Elements Equal to 1 | C++ Python | O(n^2) | O(1) | Medium | Math, Number Theory, Constructive Algorithms |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
1146 | Snapshot Array | C++ Python | set: O(1) get: O(logn) |
O(n) | Medium | ||
1166 | Design File System | C++ Python | create: O(n) get: O(n) |
O(n) | Medium | π | |
1172 | Dinner Plate Stacks | C++ Python | push: O(logn) pop: O(1), amortized popAtStack: (logn) |
O(n * c) | Hard | ||
1206 | Design Skiplist | C++ Python | O(logn), on average | O(n) | Hard | ||
1236 | Web Crawler | C++ Python | O(|V| + |E|) | O(|V|) | Medium | π | BFS, DFS |
1244 | Design A Leaderboard | C++ Python | ctor: O(1) add: O(1) top: O(n) reset: O(1) |
O(n) | Medium | ||
1268 | Search Suggestions System | C++ Python | ctor: O(n * l) suggest: O(l^2) |
O(t) | Medium | Trie | |
1286 | Iterator for Combination | C++ Python | O(k) | O(k) | Medium | Stack | |
1348 | Tweet Counts Per Frequency | C++ Python | add: O(logn) query: O(c) |
O(n) | Medium | ||
1352 | Product of the Last K Numbers | C++ Python | ctor: O(1) add: O(1) get: O(1) |
O(n) | Medium | ||
1357 | Apply Discount Every n Orders | C++ Python | ctor: O(m) getBill: O(p) |
O(m) | Medium | ||
1381 | Design a Stack With Increment Operation | C++ Python | ctor: O(1) push: O(1) pop: O(1) increment: O(1) |
O(n) | Medium | ||
1396 | Design Underground System | C++ Python | ctor: O(1) checkin: O(1) checkout: O(1) getaverage: O(1) |
O(n) | Medium | ||
1429 | First Unique Number | C++ Python | ctor: O(k) add: O(1) showFirstUnique: O(1) |
O(n) | Medium | π | LinkedHashSet |
1472 | Design Browser History | C++ Python | ctor: O(1) visit: O(1) back: O(1) forward: O(1) |
O(n) | Medium | ||
1476 | Subrectangle Queries | C++ Python | ctor: O(1) update: O(1) get: O(u) |
O(u) | Medium | ||
1483 | Kth Ancestor of a Tree Node | C++ Python | ctor: O(n * logh) get: O(logh) |
O(n * logh) | Hard | DP, Binary Lifting | |
1500 | Design a File Sharing System | C++ Python | ctor: O(1) join: O(logu + c) leave: O(logu + c) request: O(u) |
O(u * c) | Medium | π | |
1570 | Dot Product of Two Sparse Vectors | C++ Python | ctor: O(n) dot_product: O(min(n, m)) |
O(n) | Medium | π | |
1586 | Binary Search Tree Iterator II | C++ Python | O(1), amortized | O(h) | Medium | π | |
1600 | Throne Inheritance | C++ Python | ctor: O(1) birth: O(1) death: O(1) inherit: O(n) |
O(n) | Medium | ||
1603 | Design Parking System | C++ Python | O(1) | O(1) | Easy | ||
1622 | Fancy Sequence | C++ Python | O(1) | O(n) | Hard | Euler's Theorem |
|
1628 | Design an Expression Tree With Evaluate Function | C++ Python | O(n) | O(h) | Medium | π | |
1656 | Design an Ordered Stream | C++ Python | O(1), amortized | O(n) | Easy | ||
1670 | Design Front Middle Back Queue | C++ Python | O(1) | O(n) | Medium | ||
1756 | Design Most Recently Used Queue | C++ Python | ctor: O(nlogn) fetch: O(logn) |
O(n) | Medium | π | Sorted List, BIT, Fenwick Tree, Square Root Decomposition |
1797 | Design Authentication Manager | C++ Python | ctor: O(1) generate: O(1), amortized renew: O(1), amortized count: O(1), amortized |
O(n) | Medium | OrderedDict | |
1804 | Implement Trie II (Prefix Tree) | C++ Python | ctor: O(1) insert: O(n) count_word: O(n) count_prefix: O(n) erase: O(n) |
O(t) | Medium | π | Trie |
1825 | Finding MK Average | C++ Python | ctor: O(1) add_element: O(logn) calc_mkaverge: O(1) |
O(m) | Hard | Sorted List | |
1845 | Seat Reservation Manager | C++ Python | ctor: O(n) reserve: O(logn) unreserve: O(logn) |
O(n) | Medium | Heap | |
1865 | Finding Pairs With a Certain Sum | C++ Python | ctor: O(n1 + n2) add: O(1) count: O(n1) |
O(n1 + n2) | Medium | Hash Table | |
1912 | Design Movie Rental System | C++ Python | ctor: O(nlogn) search: O(logn) rent: O(logn) drop: O(logn) report: O(logn) |
O(n) | Hard | Ordered List | |
1993 | Operations on Tree | C++ Python | ctor: O(n) lock: O(1) unlock: O(1) upgrade: O(n) |
O(n) | Medium | ||
2013 | Detect Squares | C++ Python | ctor: O(1) add: O(1) count: O(n) |
O(n) | Medium | ||
2034 | Stock Price Fluctuation | C++ Python | ctor: O(1) update: O(logn) current: O(1) max: O(1) min: O(1) |
O(n) | Medium | Sorted List, Heap | |
2043 | Simple Bank System | C++ Python | ctor: O(1) transer: O(1) deposit: O(1) withdraw: O(1) |
O(1) | Medium | ||
2069 | Walking Robot Simulation II | C++ Python | O(1) | O(1) | Medium | Simulation, Math | |
2080 | Range Frequency Queries | C++ Python | ctor: O(n) query: O(logn) |
O(n) | Medium | Binary Search | |
2102 | Sequentially Ordinal Rank Tracker | C++ Python | add: O(logn) get: O(logn) |
O(n) | Hard | Sorted List | |
2166 | Design Bitset | C++ Python | ctor: O(n) fix: O(1) fix: O(1) unfix: O(1) flip: O(1) all: O(1) one: O(1) count: O(1) toString: O(n) |
O(n) | Medium | ||
2227 | Encrypt and Decrypt Strings | C++ Python | ctor: O(m + d) encrypt: O(n) decrypt: O(n) |
O(n) | Hard | Freq Table | |
2241 | Design an ATM Machine | C++ Python | ctor: O(1) deposit: O(1) withdraw: O(1) |
O(1) | Medium | Greedy | |
2254 | Design Video Sharing Platform | C++ Python | ctor: O(1) upload: O(logn + l) remove: O(logn) like: O(1) dislike: O(1) view: O(1) getLikesAndDislikes: O(1) getViews: O(1) |
O(n * l) | Hard | π | Heap |
2276 | Count Integers in Intervals | C++ Python | ctor: O(1) add: O(logn), amortized Count: O(1) |
O(n) | Hard | Sorted List | |
2286 | Booking Concert Tickets in Groups | C++ Python | ctor: O(n) gather: O(logn) scatter: O(logn), amortized |
O(n) | Hard | Segment Tree, Binary Search | |
2296 | Design a Text Editor | C++ Python | ctor: O(1) addText: O(l) deleteText: O(k) cursorLeft: O(k) cursorRight: O(k) |
O(n) | Hard | Stack | |
2336 | Smallest Number in Infinite Set | C++ Python | ctor: O(1) popSmallest: O(logn) addBack: O(logn) |
O(n) | Medium | Heap, BST | |
2349 | Design a Number Container System | C++ Python | ctor: O(1) change: O(logn) find: O(1) |
O(n) | Medium | Sorted List, BST | |
2353 | Design a Food Rating System | C++ Python | ctor: O(nlogn) changeRating: O(logn) highestRated: O(1) |
O(n) | Medium | Sorted List, BST | |
2408 | Design SQL | C++ Python | ctor: O(t * max_m) insertRow: O(m) deleteRow: O(1) selectCell: O(m) |
O(d) | Medium | π | Hash Table |
2424 | Longest Uploaded Prefix | C++ Python | ctor: O(1) upload: O(1), amortized longest: O(1) |
O(n) | Medium | Hash Table | |
2502 | Design Memory Allocator | C++ Python | ctor: O(1) allocate: O(logn) free: O(logn) |
O(n) | Medium | Sorted List | |
2526 | Find Consecutive Integers from a Data Stream | C++ Python | O(1) | O(1) | Medium | Array | |
2590 | Design a Todo List | C++ Python | ctor: O(1) addTask: O(l + logn) getAllTasks: O(r) getTasksForTag: O(r * c) completeTask: O(l + logn) |
O(n * l) | Medium | π | BST, Sorted List |
2642 | Design Graph With Shortest Path Calculator | C++ Python | ctor: O(|V| + |E|) addEdge: O(1) shortestPath: O(|E| * log|V|) |
O(|E|) | Hard | Dijkstra's Algorithm |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
1114 | Print in Order | C++ Python | O(n) | O(1) | Easy | ||
1115 | Print FooBar Alternately | C++ Python | O(n) | O(1) | Medium | ||
1116 | Print Zero Even Odd | C++ Python | O(n) | O(1) | Medium | ||
1117 | Building H2O | C++ Python | O(n) | O(1) | Hard | ||
1188 | Design Bounded Blocking Queue | C++ Python | O(n) | O(1) | Medium | π | |
1195 | Fizz Buzz Multithreaded | C++ Python | O(n) | O(1) | Medium | ||
1226 | The Dining Philosophers | C++ Python | O(n) | O(1) | Medium | ||
1242 | Web Crawler Multithreaded | C++ Python | O(|V| + |E|) | O(|V|) | Medium | π | |
1279 | Traffic Light Controlled Intersection | C++ Python | O(n) | O(1) | Easy | π |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
2618 | Check if Object Instance of Class | TypeScript | O(n) | O(1) | Medium | ||
2619 | Array Prototype Last | TypeScript | O(1) | O(1) | Easy | ||
2620 | Counter | TypeScript | O(1) | O(1) | Easy | ||
2621 | Sleep | TypeScript | O(1) | O(1) | Easy | Promise | |
2622 | Cache With Time Limit | TypeScript | O(1) | O(1) | Medium | Hash Table | |
2623 | Memoize | TypeScript | O(1) | O(1) | Medium | Hash Table | |
2624 | Snail traversal | TypeScript | O(m * n) | O(1) | Medium | ||
2625 | Flatten Deeply Nested Array | TypeScript | O(n) | O(h) | Medium | DFS | |
2626 | Array Reduce Transformation | TypeScript | O(n) | O(1) | Easy | ||
2627 | Debounce | TypeScript | O(1) | O(1) | Medium | ||
2628 | JSON Deep Equal | TypeScript | O(n) | O(h) | Medium | DFS | |
2629 | Function Composition | TypeScript | O(n) | O(1) | Easy | ||
2630 | Memoize II | TypeScript | O(n) | O(t) | Hard | Trie | |
2631 | Group By | TypeScript | O(n) | O(1) | Medium | ||
2632 | Curry | TypeScript | O(n) | O(n) | Medium | ||
2633 | Convert Object to JSON String | TypeScript | O(n) | O(h) | Medium | DFS | |
2634 | Filter Elements from Array | TypeScript | O(n) | O(1) | Easy | ||
2635 | Apply Transform Over Each Element in Array | TypeScript | O(n) | O(1) | Easy | ||
2636 | Promise Pool | TypeScript | O(c + n / c) | O(c) | Medium | Promise | |
2637 | Promise Time Limit | TypeScript | O(n) | O(1) | Easy | Promise | |
2648 | Generate Fibonacci Sequence | TypeScript | O(1) | O(1) | Easy | DP | |
2649 | Nested Array Generator | TypeScript | O(1) | O(d) | Medium | DFS | |
2650 | Design Cancellable Function | TypeScript | O() | O(1) | Hard | Promise |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|