- 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 repository.
- For more challenging problem solutions, you can also see my GoogleCodeJam, FacebookHackerCup 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
- Two Pointers
- Sort
- Recursion
- Binary Search
- Binary Search Tree
- Breadth-First Search
- Depth-First Search
- Backtracking
- Dynamic Programming
- Greedy
- Graph
- Geometry
- Simulation
- Design
- Concurrency
- C++
- Python
- Reverse: what connections are needed, point to a pre node
- Start from end: reverse twice, stack, recursion (not work if length not aligned) 206, 445
- Tip: dummy node at the beginning
- parentheses: counters of opening/closing parentheses, or stack if order matters
- count depth
- Stack for nested: push stack when open parentheses, pop stack when close
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
0020 | Valid Parentheses | C++ Python | O(n) | O(n) | Easy | ||
0032 | Longest Valid Parentheses | C++ Python | O(n) | O(1) | Hard | Review | Double Scan |
0071 | Simplify Path | C++ Python | O(n) | O(n) | Medium | ||
0084 | Largest Rectangle in Histogram | C++ Python | O(n) | O(n) | Hard | Review | Mono Stack, DP |
0085 | Maximal Rectangle | C++ Python | O(m * n) | O(n) | Hard | Review, EPI | Mono Stack |
0101 | Symmetric Tree | C++ Python | O(n) | O(h) | Easy | ||
0150 | Evaluate Reverse Polish Notation | C++ Python | O(n) | O(n) | Medium | ||
0155 | Min Stack | C++ Python | O(n) | O(1) | Easy | Review | |
0224 | Basic Calculator | C++ Python | O(n) | O(n) | Hard | Review | |
0227 | Basic Calculator II | C++ Python | O(n) | O(n) | Medium | Review | |
0232 | Implement Queue using Stacks | C++ Python | O(1), amortized | O(n) | Easy | EPI, LintCode | |
0255 | Verify Preorder Sequence in Binary Search Tree | C++ Python | O(n) | O(1) | Medium | 🔒Review | Mono Stack |
0272 | Closest Binary Search Tree Value II | C++ Python | O(h + k) | O(h) | Hard | 🔒 GiveUp | |
0331 | Verify Preorder Serialization of a Binary Tree | C++ Python | O(n) | O(1) | Medium | Review | |
0341 | Flatten Nested List Iterator | C++ Python | O(n) | O(h) | Medium | Review | Iterator |
0385 | Mini Parser | C++ Python | O(n) | O(h) | Medium | Review | Stack for nested |
0394 | Decode String | C++ Python | O(n) | O(n) | Medium | Review | Stack for nested |
0439 | Ternary Expression Parser | C++ Python | O(n) | O(1) | Medium | 🔒 | |
0456 | 132 Pattern | C++ Python | O(n) | O(n) | Medium | Review | Mono Stack |
0496 | Next Greater Element I | C++ Python | O(m+n) | O(n) | Medium | Review | Mono Stack |
0503 | Next Greater Element II | C++ Python | O(n) | O(n) | Medium | Review | Mono Stack |
0636 | Exclusive Time of Functions | C++ Python | O(n) | O(n) | Medium | ||
0682 | Baseball Game | C++ Python | O(n) | O(n) | Easy | ||
0726 | Number of Atoms | C++ Python | O(n) | O(n) | Hard | Review | |
0735 | Asteroid Collision | C++ Python | O(n) | O(n) | Medium | ||
0736 | Parse Lisp Expression | C++ Python | O(n^2) | O(n^2) | Hard | Giveup | |
0739 | Daily Temperatures | C++ Python | O(n) | O(n) | Medium | Mono Stack | |
0770 | Basic Calculator IV | C++ Python | add: O(d * t) sub: O(d * t) mul: O(d * t^2) eval: O(d * t) to_list: O(d * tlogt) |
O(e + d * t) | Hard | Giveup | |
0772 | Basic Calculator III | C++ Python | O(n) | O(n) | Hard | ||
0853 | Car Fleet | C++ Python | O(nlogn) | O(n) | Medium | ||
0856 | Score of Parentheses | C++ Python | O(n) | O(1) | Medium | Review | |
0872 | Leaf-Similar Trees | C++ Python | O(n) | O(h) | Easy | ||
0895 | Maximum Frequency Stack | C++ Python | O(1) | O(n) | Hard | Review | Hash |
0901 | Online Stock Span | C++ Python | O(n) | O(n) | Medium | Mono Stack | |
0921 | Minimum Add to Make Parentheses Valid | C++ Python | O(n) | O(1) | Medium | Review | Add+Bal |
0946 | Validate Stack Sequences | C++ Python | O(n) | O(n) | Medium | ||
1003 | Check If Word Is Valid After Substitutions | C++ Python | O(n) | O(n) | Medium | ||
1019 | Next Greater Node In Linked List | C++ Python | O(n) | O(n) | Medium | Mono Stack | |
1021 | Remove Outermost Parentheses | C++ Python | O(n) | O(1) | Easy | Review | |
1047 | Remove All Adjacent Duplicates In String | C++ Python | O(n) | O(n) | Easy | ||
1063 | Number of Valid Subarrays | C++ Python | O(n) | O(n) | Hard | Review 🔒 | Mono Stack |
1130 | Minimum Cost Tree From Leaf Values | C++ Python | O(n) | O(n) | Hard | Review | Mono Stack |
1190 | Reverse Substrings Between Each Pair of Parentheses | C++ Python | O(n) | O(n) | Medium | Review | Stack for nested, match parentheses |
1209 | Remove All Adjacent Duplicates in String II | C++ Python | O(n) | O(n) | Medium | ||
1441 | Build an Array With Stack Operations | C++ Python | O(n) | O(1) | Easy | ||
1541 do | Minimum Insertions to Balance a Parentheses String | C++ Python | O(n) | O(1) | Medium | Add+Bal | |
1597 | Build Binary Expression Tree From Infix Expression | C++ Python | O(n) | O(n) | Medium | 🔒, variant of Basic Calculator III |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
0239 | Sliding Window Maximum | C++ Python | O(n) | O(k) | Hard | Review, EPI, LintCode | Mono Deque |
0281 | Zigzag Iterator | C++ Python | O(n) | O(k) | Review, Medium | 🔒 | |
0346 | Moving Average from Data Stream | C++ Python | O(1) | O(w) | Easy | 🔒 | |
0862 do | Shortest Subarray with Sum at Least K | C++ Python | O(n) | O(n) | Hard | Mono Deque, Sliding Window | |
0933 | Number of Recent Calls | C++ Python | O(1) on average | O(w) | Easy | ||
1424 do | Diagonal Traverse II | C++ Python | O(m * n) | O(m) | Medium | ||
1425 do | Constrained Subset Sum | C++ Python | O(n) | O(k) | Hard | variant of Sliding Window Maximum | Mono Deque, Sliding Window |
1438 do | 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 |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
0264 | Ugly Number II | C++ Python | O(n) | O(n) | Medium | Review, CTCI, LintCode | Heap, DP |
0295 | Find Median from Data Stream | C++ Python | O(nlogn) | O(n) | Hard | Review, EPI, LintCode | BST, Heap |
0313 | Super Ugly Number | C++ Python | O(n * k) | O(n + k) | Medium | BST, Heap | |
0358 | Rearrange String k Distance Apart | C++ Python | O(n) | O(n) | Hard | 🔒 | Greedy, Heap |
0373 | Find K Pairs with Smallest Sums | C++ Python | O(k * log(min(n, m, k))) | O(min(n, m, k)) | Medium | ||
0378 | Kth Smallest Element in a Sorted Matrix | C++ Python | O(k * log(min(n, m, k))) | O(min(n, m, k)) | Medium | LintCode | |
0407 | Trapping Rain Water II | C++ Python | O(m * n * (logm + logn)) | O(m * n) | Hard | LintCode | |
0632 | Smallest Range | C++ Python | O(nlogk) | O(k) | Hard | Review | |
0703 | Kth Largest Element in a Stream | C++ Python | O(nlogk) | O(k) | Easy | ||
0846 | Hand of Straights | C++ Python | O(nlogn) | O(n) | Medium | ||
0855 | Exam Room | C++ Python | seat: O(logn) leave: O(logn) |
O(n) | Medium | BST, Hash | |
0857 | Minimum Cost to Hire K Workers | C++ Python | O(nlogn) | O(n) | Hard | Sort | |
0871 | Minimum Number of Refueling Stops | C++ Python | O(nlogn) | O(n) | Hard | Sort | |
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 | 🔒 | |
1383 | Maximum Performance of a Team | C++ Python | O(nlogn) | O(n) | Hard | variant of Minimum Cost to Hire K Workers | Sort |
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 | SortedList | |
1642 | Furthest Building You Can Reach | C++ Python | O(nlogk) | O(k) | Medium |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
xxxx | [Collect Coins On The Tree] | Python | O(V+E) | Medium | Tree Dynamic Programming | ||
0094 | Binary Tree Inorder Traversal | C++ Python | O(n) | O(1) | Medium | Morris Traversal |
|
0099 | Recover Binary Search Tree | C++ Python | O(n) | O(1) | Hard | Morris Traversal |
|
0144 | Binary Tree Preorder Traversal | C++ Python | O(n) | O(1) | Medium | Morris Traversal |
|
0145 | Binary Tree Postorder Traversal | C++ Python | O(n) | O(1) | Hard | Morris Traversal |
|
0208 | Implement Trie (Prefix Tree) | C++ Python | O(n) | O(1) | Medium | Trie | |
0211 | Add and Search Word - Data structure design | C++ Python | O(min(n, h)) | O(min(n, h)) | Medium | Trie, DFS | |
0226 | Invert Binary Tree | C++ Python | O(n) | O(h), O(w) | Easy | ||
0297 | Serialize and Deserialize Binary Tree | C++ Python | O(n) | O(h) | Hard | LintCode | DFS |
0307 | Range Sum Query - Mutable | C++ Python | ctor: O(n), update: O(logn), query: O(logn) | O(n) | Medium | LintCode | DFS, Segment Tree, BIT, Fenwick Tree |
0308 | Range Sum Query 2D - Mutable | C++ Python | ctor: O(m * n), update: O(logm * logn), query: O(logm * logn) | O(m * n) | Hard | 🔒 | DFS, Segment Tree, BIT, Fenwick Tree |
0315 do | Count of Smaller Numbers After Self | C++ Python | O(nlogn) | O(n) | Hard | LintCode | BST, BIT, Fenwick Tree, Divide and Conquer, Merge Sort 动态序列前缀和 离散化去重排序 |
0493 do | Reverse Pairs | Python | O(nlogn) | O(n) | Hard | Fenwick Tree, Divide and Conquer 动态序列前缀和 离散化去重排序 | |
0525 | Contiguous Array | C++ Python | O(n) | O(n) | Medium | longest subarray | |
0529 | Minesweeper | C++ Python | O(m * n) | O(m + n) | Medium | BFS | |
0536 | Construct Binary Tree from String | C++ Python | O(n) | O(h) | Medium | 🔒 | |
0538 | Convert BST to Greater Tree | C++ Python | O(n) | O(h) | Easy | ||
0543 | Diameter of Binary Tree | C++ Python | O(n) | O(h) | Easy | ||
0545 | Boundary of Binary Tree | C++ Python | O(n) | O(h) | Medium | 🔒 | |
0548 | Split Array with Equal Sum | C++ Python | O(n^2) | O(n) | Medium | 🔒 | prefix sum |
0563 | Binary Tree Tilt | C++ Python | O(n) | O(n) | Easy | ||
0572 | Subtree of Another Tree | C++ Python | O(m * n) | O(h) | Easy | ||
0606 | Construct String from Binary Tree | C++ Python | O(n) | O(h) | Easy | ||
0617 | Merge Two Binary Trees | C++ Python | O(n) | O(h) | Easy | ||
0623 | Add One Row to Tree | C++ Python | O(n) | O(h) | Medium | ||
0637 | Average of Levels in Binary Tree | C++ Python | O(n) | O(h) | Easy | ||
0652 | Find Duplicate Subtrees | C++ Python | O(n) | O(n) | Medium | DFS, Hash | |
0653 | Two Sum IV - Input is a BST | C++ Python | O(n) | O(h) | Easy | Two Pointers | |
0654 | Maximum Binary Tree | C++ Python | O(n) | O(n) | Medium | LintCode | Mono Stack, Cartesian Tree |
0655 | Print Binary Tree | C++ Python | O(n) | O(h) | Medium | ||
0662 | Maximum Width of Binary Tree | C++ Python | O(n) | O(h) | Medium | DFS | |
0663 | Equal Tree Partition | C++ Python | O(n) | O(n) | Medium | 🔒 | Hash |
0677 | Map Sum Pairs | C++ Python | O(n) | O(t) | Medium | Trie | |
0684 | Redundant Connection | C++ Python | O(n) | O(n) | Medium | Union Find | |
0685 | Redundant Connection II | C++ Python | O(n) | O(n) | Hard | Union Find | |
0687 | Longest Univalue Path | C++ Python | O(n) | O(h) | Easy | ||
0699 | Falling Squares | C++ Python | O(nlogn) | O(n) | Hard | Segment Tree | |
0814 | Binary Tree Pruning | C++ Python | O(n) | O(h) | Medium | DFS | |
0850 | Rectangle Area II | C++ Python | O(nlogn) | O(n) | Hard | Segment Tree | |
0863 | All Nodes Distance K in Binary Tree | C++ Python | O(n) | O(n) | Medium | DFS + BFS | |
0865 | Smallest Subtree with all the Deepest Nodes | C++ Python | O(n) | O(h) | Medium | DFS | |
0889 | Construct Binary Tree from Preorder and Postorder Traversal | C++ Python | O(n) | O(h) | Medium | DFS, stack | |
0897 | Increasing Order Search Tree | C++ Python | O(n) | O(h) | Easy | DFS | |
0919 | Complete Binary Tree Inserter | C++ Python | ctor: O(n) insert: O(1) get_root: O(1) |
O(n) | Medium | ||
0938 | Range Sum of BST | C++ Python | O(n) | O(h) | Medium | DFS | |
0951 | Flip Equivalent Binary Trees | C++ Python | O(n) | O(h) | Medium | DFS | |
0958 | Check Completeness of a Binary Tree | C++ Python | O(n) | O(w) | Medium | BFS | |
0965 | Univalued Binary Tree | C++ Python | O(n) | O(h) | Easy | DFS | |
0971 | Flip Binary Tree To Match Preorder Traversal | C++ Python | O(n) | O(h) | Medium | DFS | |
0979 | Distribute Coins in Binary Tree | C++ Python | O(n) | O(h) | Medium | DFS | |
0987 | Vertical Order Traversal of a Binary Tree | C++ Python | O(nlogn) | O(n) | Medium | DFS | |
0988 | Smallest String Starting From Leaf | C++ Python | O(n + l * h) | O(h) | Medium | DFS | |
0993 | Cousins in Binary Tree | C++ Python | O(n) | O(h) | Easy | DFS | |
0998 | Maximum Binary Tree II | C++ Python | O(h) | O(1) | Medium | Cartesian Tree | |
1008 | Construct Binary Search Tree from Preorder Traversal | C++ Python | O(n) | O(h) | Medium | BSTbound | |
1022 | Sum of Root To Leaf Binary Numbers | C++ Python | O(n) | O(h) | Easy | ||
1026 | Maximum Difference Between Node and Ancestor | C++ Python | O(n) | O(h) | Medium | DFS | |
1028 | Recover a Tree From Preorder Traversal | C++ Python | O(n) | O(h) | Hard | DFS | |
1032 | Stream of Characters | C++ C++ Python Python | ctor: O(n) query: O(m) |
O(t) | Hard | Aho-Corasick Automata , Trie |
|
1038 | Binary Search Tree to Greater Sum Tree | C++ Python | O(n) | O(h) | Medium | DFS | |
1065 | Index Pairs of a String | C++ Python | O(n + m + z) | O(t) | Easy | 🔒 | Aho-Corasick Automata , Trie |
1080 | Insufficient Nodes in Root to Leaf Paths | C++ Python | O(n) | O(h) | Medium | DFS | |
1104 | Path In Zigzag Labelled Binary Tree | C++ Python | O(logn) | O(logn) | Easy | Math | |
1120 | Maximum Average Subtree | C++ Python | O(n) | O(h) | Easy | 🔒 | DFS |
1123 | Lowest Common Ancestor of Deepest Leaves | C++ Python | O(n) | O(h) | Medium | DFS | |
1145 | Binary Tree Coloring Game | C++ Python | O(n) | O(h) | Medium | DFS | |
1257 | Smallest Common Region | C++ Python | O(m * n) | O(n) | Medium | ||
1261 | Find Elements in a Contaminated Binary Tree | C++ Python | O(n) | O(h) | Medium | DFS | |
1325 | Delete Leaves With a Given Value | C++ Python | O(n) | O(h) | Medium | DFS | |
1339 | Maximum Product of Splitted Binary Tree | C++ Python | O(n) | O(h) | Medium | DFS | |
1409 | Queries on a Permutation With Key | C++ Python | O(nlogn) | O(n) | Medium | BIT, Fenwick Tree | |
1430 | Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree | C++ Python | O(n) | O(h) | Medium | 🔒 | BFS, DFS, Stack |
1443 | Minimum Time to Collect All Apples in a Tree | C++ Python | O(n) | O(n) | Medium | DFS, Stack | |
1448 | Count Good Nodes in Binary Tree | C++ Python | O(n) | O(h) | Medium | DFS, Stack | |
1457 | Pseudo-Palindromic Paths in a Binary Tree | C++ Python | O(n) | O(h) | Medium | DFS, Stack | |
1469 | Find All The Lonely Nodes | C++ Python | O(n) | O(h) | Easy | 🔒 | DFS, Stack |
1490 | Clone N-ary Tree | C++ Python | O(n) | O(h) | Medium | 🔒 | DFS, Stack |
1505 | Minimum Possible Integer After at Most K Adjacent Swaps On Digits | C++ Python | O(nlogn) | O(n) | Hard | BIT, Fenwick Tree | |
1506 | Find Root of N-Ary Tree | C++ Python | O(n) | O(1) | Medium | 🔒 | Bit Manipulation |
1516 | Move Sub-Tree of N-Ary Tree | C++ Python | O(n) | O(h) | Hard | 🔒 | DFS, Stack |
1519 | Number of Nodes in the Sub-Tree With the Same Label | C++ Python | O(n) | O(h) | Medium | DFS, Stack | |
1522 | Diameter of N-Ary Tree | C++ Python | O(n) | O(h) | Medium | 🔒 | DFS, Stack |
1530 | Number of Good Leaf Nodes Pairs | C++ Python | O(n) | O(h) | Medium | DFS, Stack | |
1612 | Check If Two Expression Trees are Equivalent | C++ Python | O(n) | O(1) | Medium | 🔒 | Morris Traversal , Inorder Traversal, Stack, Hash Table |
1649 | Create Sorted Array through Instructions | C++ Python | O(nlogn) | O(n) | Hard | variant of Count of Smaller Numbers After Self | BIT, Fenwick Tree, Merge Sort |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
0056 | Merge Intervals | C++ Python | O(nlogn) | O(1) | Hard | ||
0057 | Insert Interval | C++ Python | O(n) | O(1) | Hard | ||
0075 | Sort Colors | C++ Python | O(n) | O(1) | Medium | Tri Partition, Swap | |
0088 | Merge Sorted Array | C++ Python | O(n) | O(1) | Easy | ||
0147 | Insertion Sort List | C++ Python | O(n^2) | O(1) | Medium | ||
0148 | Sort List | C++ Python | O(nlogn) | O(logn) | Medium | ||
0164 | Maximum Gap | C++ Python | O(n) | O(n) | Hard | Tricky | |
0179 | Largest Number | C++ Python | O(nlogn) | O(1) | Medium | ||
0218 | The Skyline Problem | C++ Python | O(nlogn) | O(n) | Hard | Sort, BST | |
0252 | Meeting Rooms | C++ Python | O(nlogn) | O(n) | Easy | 🔒 | |
0253 | Meeting Rooms II | C++ Python | O(nlogn) | O(n) | Medium | Review🔒 | |
0274 | H-Index | C++ Python | O(n) | O(n) | Medium | Review | Counting Sort |
0280 | Wiggle Sort | C++ Python | O(n) | O(1) | Medium | 🔒 | |
0324 | Wiggle Sort II | C++ Python | O(n) on average | O(1) | Medium | variant of Sort Colors | Tri Partition |
0347 | Top K Frequent Elements | C++ Python | O(n) | O(n) | Medium | Review | Bucket Sort, Quick Select, Heap |
0406 | Queue Reconstruction by Height | C++ Python | O(n * sqrt(n)) | O(n) | Medium | Tricky | |
0451 | Sort Characters By Frequency | C++ Python | O(n) | O(n) | Medium | ||
0692 | Top K Frequent Words | C++ Python | O(n + klogk) on average | O(n) | Medium | Review | Quick Select, Heap, Bucket Sort |
0912 | Sort an Array | C++ Python | O(nlogn) | O(n) | Medium | Merge Sort, Quick Sort | |
0937 | Reorder Log Files | C++ Python | O(nlogn * l) | O(l) | Easy | ||
0969 | Pancake Sorting | C++ Python | O(nlogn) | O(n) | Medium | variant of Count of Smaller Numbers After Self | BIT, Fenwick Tree, Merge Sort |
0973 | K Closest Points to Origin | C++ Python | O(n) on average | O(1) | Easy | Quick Select, Heap | |
0976 | Largest Perimeter Triangle | C++ Python | O(nlogn) | O(1) | Easy | ||
1054 | Distant Barcodes | C++ Python | O(klogk) | 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 do | Meeting Scheduler | C++ Python | O(n) ~ 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 |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
0015 | 3 Sum | C++ Python | O(n^2) | O(1) | Medium | Two Pointers | |
0016 | 3 Sum Closest | C++ Python | O(n^2) | O(1) | Medium | Two Pointers | |
0018 | 4 Sum | C++ Python | O(n^3) | O(1) | Medium | Two Pointers | |
0019 | Remove Nth Node From End of List | C++ Python | O(n) | O(1) | Medium | ||
0086 | Partition List | C++ Python | O(n) | O(1) | Medium | ||
0141 | Linked List Cycle | C++ Python | O(n) | O(1) | Easy | ||
0142 do | Linked List Cycle II | C++ Python | O(n) | O(1) | Medium | ||
0143 do | Reorder List | C++ Python | O(n) | O(1) | Medium | ||
0167 | Two Sum II - Input array is sorted | C++ Python | O(n) | O(1) | Medium | ||
0209 | Minimum Size Subarray Sum | C++ Python | O(n) | O(1) | Medium | Binary Search, Sliding Window | |
0259 | 3Sum Smaller | C++ Python | O(n^2) | O(1) | Medium | 🔒, LintCode | |
0283 | Move Zeroes | C++ Python | O(n) | O(1) | Easy | ||
0287 | Find the Duplicate Number | C++ Python | O(n) | O(1) | Hard | Binary Search, Two Pointers | |
0344 | Reverse String | C++ Python | O(n) | O(1) | Easy | ||
0345 | Reverse Vowels of a String | C++ Python | O(n) | O(1) | Easy | ||
0349 | Intersection of Two Arrays | C++ Python | O(m + n) | O(min(m, n)) | Easy | EPI | Hash, Binary Search |
0350 | Intersection of Two Arrays II | C++ Python | O(m + n) | O(1) | Easy | EPI | Hash, Binary Search |
0360 | Sort Transformed Array | C++ Python | O(n) | O(1) | Medium | 🔒 | |
0424 | Longest Repeating Character Replacement | C++ Python | O(n) | O(1) | Medium | Sliding Window | |
0457 | Circular Array Loop | C++ Python | O(n) | O(1) | Medium | ||
0567 | Permutation in String | C++ Python | O(n) | O(1) | Medium | Slide Window | |
0611 | Valid Triangle Number | C++ Python | O(n^2) | O(1) | Medium | ||
0777 | Swap Adjacent in LR String | C++ Python | O(n) | O(1) | Medium | ||
0826 | Most Profit Assigning Work | C++ Python | O(mlogm + nlogn) | O(n) | Medium | ||
0828 | Count Unique Characters of All Substrings of a Given String | C++ Python | O(n) | O(1) | Hard | ||
0844 | Backspace String Compare | C++ Python | O(m + n) | O(1) | Easy | ||
0876 | Middle of the Linked List | C++ Python | O(n) | O(1) | Easy | ||
0904 | Fruit Into Baskets | C++ Python | O(n) | O(1) | Medium | Sliding Window | |
0930 | Binary Subarrays With Sum | C++ Python | O(n) | O(1) | Medium | Sliding Window | |
0977 | Squares of a Sorted Array | C++ Python | O(n) | O(1) | Easy | ||
0992 | Subarrays with K Different Integers | C++ Python | O(n) | O(k) | Hard | Two Pointers, Sliding Window | |
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 | |
1169 | Invalid Transactions | C++ Python | O(nlogn) | O(n) | Medium | Sliding Window, Line Sweep | |
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 | 🔒 | |
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 do | 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 |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
xxx | Dijkstra's Algorithm | Python | Medium | Dijkstra's algorithm |
|||
0102 | Binary Tree Level Order Traversal | C++ Python | O(n) | O(n) | Easy | ||
0107 | Binary Tree Level Order Traversal II | C++ Python | O(n) | O(n) | Easy | ||
0103 | Binary Tree Zigzag Level Order Traversal | Python | O(n) | O(n) | Medium | ||
0117 | Populating Next Right Pointers in Each Node II | Python | O(n) | O(1) | Hard | ||
0127 | Word Ladder | C++ Python | O(b^(d/2)) | O(w * l) | Medium | CTCI | Bi-BFS |
0130 | Surrounded Regions | C++ Python | O(m * n) | O(m + n) | Medium | ||
0133 | Clone Graph | Python | O(n) | O(n) | Medium | ||
0207 | Course Schedule | C++ Python | O(|V| + |E|) | O(|E|) | Medium | Topological Sort | |
0210 | Course Schedule II | C++ Python | O(|V| + |E|) | O(|E|) | Medium | Topological Sort | |
0261 | Graph Valid Tree | C++ Python | O(|V| + |E|) | O(|V| + |E|) | Medium | 🔒 | |
0269 | Alien Dictionary | C++ Python | O(n) | O(1) | Hard | 🔒 | Topological Sort, BFS, DFS |
0286 | Walls and Gates | C++ Python | O(m * n) | O(g) | Medium | Review 🔒 | |
0310 | Minimum Height Trees | C++ Python | O(n) | O(n) | Medium | ||
0317 | Shortest Distance from All Buildings | C++ Python | O(k * m * n) | O(m * n) | Hard | 🔒 | |
0433 | Minimum Genetic Mutation | C++ Python | O(n * b) | O(b) | Medium | ||
0444 | Sequence Reconstruction | C++ Python | O(n * s) | O(n) | Medium | 🔒 | Topological Sort |
0490 | The Maze | C++ Python | O(max(r, c) * w) | O(w) | Medium | ||
0499 | The Maze III | C++ Python | O(max(r, c) * wlogw) | O(w^2) | Hard | ||
0505 | The Maze II | C++ Python | O(max(r, c) * wlogw) | O(w) | Medium | ||
0542 | 01 Matrix | C++ Python | O(m * n) | O(1) | Medium | DP | |
0666 | Path Sum IV | C++ Python | O(n) | O(w) | Medium | 🔒 | Topological Sort |
0675 | Cut Off Trees for Golf Event | C++ Python | O(t * m * n) | O(m * n) | Hard | A* Search Algorithm |
|
0742 | Closest Leaf in a Binary Tree | C++ Python | O(n) | O(n) | Medium | ||
0743 | Network Delay Time | C++ Python | O(|E| * log|V|) | O(|E|) | Medium | Dijkstra's Algorithm |
|
0752 | Open the Lock | C++ Python | O(k * n^k + d) | O(k * n^k + d) | Medium | ||
0773 | Sliding Puzzle | C++ Python | O((m * n) * (m * n)!) | O((m * n) * (m * n)!) | Hard | A* Search Algorithm |
|
0787 | Cheapest Flights Within K Stops | C++ Python | O(|E| * log|V|) | O(|E|) | Medium | Review | Dijkstra's Algorithm |
0815 | Bus Routes | C++ Python | O(|E| + |V|) | O(|E| + |V|) | Hard | ||
0854 | K-Similar Strings | C++ Python | O(n * n!/(c_a!*...*c_z!)) | O(n * n!/(c_a!*...*c_z!)) | Hard | ||
0864 | Shortest Path to Get All Keys | C++ Python | O(k * r * c + k^3*2^k) | O(k*2^k) | Hard | Review | Dijkstra's algorithm |
0882 | Reachable Nodes In Subdivided Graph | C++ Python | O(|E| * log|V|) | O(|E|) | Hard | Dijkstra's algorithm |
|
0886 | Possible Bipartition | C++ Python | O(|V| + |E|) | O(|V| + |E|) | Medium | ||
0934 | Shortest Bridge | C++ Python | O(n^2) | O(n^2) | Medium | BFS, DFS | |
0967 | Numbers With Same Consecutive Differences | C++ Python | O(2^n) | O(2^n) | Medium | ||
0994 | Rotting Oranges | C++ Python | O(m * n) | O(m * n) | Easy | ||
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 | 🔒 Review | 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 | ||
1163 | Last Substring in Lexicographical Order | C++ Python | O(n) | O(n) | Hard | ||
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(2^(m * n)) | Hard | Review | State in Bits |
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 | Review | |
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 |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
0112 | Path Sum | Python | O(n) | O(h) | Easy | ||
0113 | Path Sum II | Python | O(n) | O(h) | Medium | ||
0199 | Binary Tree Right Side View | Python | O(n) | O(h) | Medium | ||
0200 | Number of Islands | C++ Python | O(m * n) | O(m * n) | Medium | BFS, DFS, Union Find | |
0236 | Lowest Common Ancestor of a Binary Tree | C++ Python | O(n) | O(h) | Medium | EPI | |
0247 | Strobogrammatic Number II | C++ Python | O(n * 5^(n/2)) | O(n) | Medium | 🔒 | |
0250 | Count Univalue Subtrees | C++ Python | O(n) | O(h) | Medium | 🔒 | |
0257 | Binary Tree Paths | C++ Python | O(n * h) | O(h) | Easy | ||
0282 | Expression Add Operators | C++ Python | O(4^n) | O(n) | Hard | Review | |
0301 | Remove Invalid Parentheses | C++ Python | O(C(n, c)) | O(c) | Hard | Review | |
0329 | Longest Increasing Path in a Matrix | C++ Python | O(m * n) | O(m * n) | Hard | Review | DFS, Topological Sort |
0332 | Reconstruct Itinerary | C++ Python | O(t! / (n1! * n2! * ... nk!)) | O(t) | Medium | ||
0339 | Nested List Weight Sum | C++ Python | O(n) | O(h) | Easy | 🔒 | |
0364 | Nested List Weight Sum II | C++ Python | O(n) | O(h) | Medium | 🔒 | |
0366 | Find Leaves of Binary Tree | C++ Python | O(n) | O(h) | Medium | 🔒 | |
0417 | Pacific Atlantic Water Flow | C++ Python | O(m * n) | O(m * n) | Medium | ||
0440 | K-th Smallest in Lexicographical Order | C++ Python | O(logn) | O(logn) | Hard | ||
0463 | Island Perimeter | Python | O(m*n) | O(1) | Medium | Review | |
0464 | Can I Win | C++ Python | O(n!) | O(n) | Medium | ||
0515 | Find Largest Value in Each Tree Row | C++ Python | O(n) | O(h) | Medium | ||
0547 | Friend Circles | C++ Python | O(n^2) | O(n) | Medium | Union Find | |
0582 | Kill Process | C++ Python | O(n) | O(n) | Medium | 🔒 | DFS, BFS |
0638 | Shopping Offers | C++ Python | O(n * 2^n) | O(n) | Medium | ||
0690 | Employee Importance | C++ Python | O(n) | O(h) | Easy | DFS, BFS | |
0694 | Number of Distinct Islands | C++ Python | O(m * n) | O(m * n) | Medium | 🔒 | |
0695 | Max Area of Island | C++ Python | O(m * n) | O(m * n) | Easy | ||
0711 | Number of Distinct Islands II | C++ Python | O((m * n) * log(m * n)) | O(m * n) | Hard | 🔒 | Hash |
0733 | Flood Fill | C++ Python | O(m * n) | O(m * n) | Easy | ||
0749 | Contain Virus | C++ Python | O((m * n)^(4/3)) | O(m * n) | Hard | Simulation | |
0753 | Cracking the Safe | C++ Python | O(k^n) | O(k^n) | Hard | de Bruijn sequences , Lyndon word , Rolling Hash, Backtracking, Greedy |
|
0756 | Pyramid Transition Matrix | C++ Python | O(a^b) | O(a^b) | Medium | Review | |
0785 | Is Graph Bipartite? | C++ Python | O(|V| + |E|) | O(|V|) | Medium | ||
0797 | All Paths From Source to Target | C++ Python | O(2^n * n) | O(2^n * n) | Medium | ||
0802 | Find Eventual Safe States | C++ Python | O(|V| + |E|) | O(|V|) | Medium | ||
0827 | Making A Large Island | C++ Python | O(n^2) | O(n^2) | Hard | ||
0834 do | Sum of Distances in Tree | C++ Python | O(n) | O(n) | Hard | Tree Dynamic Programming | |
0841 | Keys and Rooms | C++ Python | O(n+e) | O(n) | Medium | ||
0851 | Loud and Rich | C++ Python | O(q + r) | O(q + r) | Medium | ||
0913 | Cat and Mouse | C++ Python | O(n^3) | O(n^2) | Hard | ||
1020 | Number of Enclaves | C++ Python | O(m * n) | O(m * n) | Medium | ||
1059 | All Paths from Source Lead to Destination | C++ Python | O(n + e) | O(n + e) | Medium | 🔒 | |
1192 | Critical Connections in a Network | C++ Python | O(|V| + |E|) | O(|V| + |E|) | Hard | Tarjan's Algorithm , Bridge Finding Algorithm |
|
1202 | Smallest String With Swaps | C++ Python | O(nlogn) | O(n) | Medium | Union Find | |
1254 | Number of Closed Islands | C++ Python | O(m * n) | O(1) | Medium | ||
1273 | Delete Tree Nodes | C++ Python | O(n) | O(n) | Medium | DFS, DP | |
1315 | Sum of Nodes with Even-Valued Grandparent | C++ Python | O(n) | O(h) | Medium | ||
1319 | Number of Operations to Make Network Connected | C++ Python | O(|E| + |V|) | O(|V|) | Medium | Union Find | |
1367 | Linked List in Binary Tree | C++ Python | O(n + l) | O(h + l) | Medium | KMP Algorithm |
|
1372 | Longest ZigZag Path in a Binary Tree | C++ Python | O(n) | O(h) | Medium | ||
1376 | Time Needed to Inform All Employees | C++ Python | O(n) | O(n) | Medium | ||
1377 | Frog Position After T Seconds | C++ Python | O(n) | O(n) | Hard | DFS, Stack, BFS | |
1391 | Check if There is a Valid Path in a Grid | C++ Python | O(m * n) | O(1) | Medium | Simulation | |
1466 | Reorder Routes to Make All Paths Lead to the City Zero | C++ Python | O(n) | O(n) | Medium | DFS, Stack | |
1485 | Clone Binary Tree With Random Pointer | C++ Python | O(n) | O(h) | Medium | 🔒 | DFS, Stack |
- Question type: Ask for all possible
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
xxx | [Minimax Sample] | Python | Medium | ||||
0017 | Letter Combinations of a Phone Number | C++ Python | O(n * 4^n) | O(n) | Medium | ||
0022 | Generate Parentheses | C++ Python | O(4^n / n^(3/2)) | O(n) | Medium | ||
0037 | Sudoku Solver | Python | O((9!)^9) | O(1) | Hard | Review | |
0039 | Combination Sum | Python | O(n * 2^n) | O(target) | Medium | ||
0040 | Combination Sum II | Python | O(n * 2^n) | O(target) | Medium | Review | |
0046 | Permutations | Python | O(n * n!) = O(n * P(n, n)) | O(n) | Medium | Review | recursion, iteration |
0047 | Permutations II | Python | O(n * n!) = O(n * P(n, n)) | O(n) | Medium | Review | |
0051 | N-Queens | Python | O(n!) | O(n) | Hard | Review | |
0052 | N-Queens-II | Python | O(n!) | O(n) | Hard | ||
0077 | Combinations | C++ Python | O(k * C(n, k)) | O(k) | Medium | ||
0078 | Subsets | C++ Python | O(n * 2^n) | O(1) | Medium | ||
0079 do | Word Search | Python | O(m * n * l) | O(l) | Medium | ||
0090 do | Subsets II | C++ Python | O(n * 2^n) | O(1) | Medium | ||
0093 do | Restore IP Addresses | Python | O(1) | O(1) | Medium | ||
0126 do | Word Ladder II | C++ Python | O(b^(d/2)) | O(w * l) | Hard | CTCI | Bi-BFS |
0131 do | Palindrome Partitioning | Python | O(n^2) ~ O(2^n) | O(n^2) | Medium | ||
0140 do | Word Break II | C++ Python | O(n * l^2 + n * r) | O(n^2) | Hard | ||
0212 do | Word Search II | C++ Python | O(m * n * 3^h) | O(t) | Hard | LintCode | Trie, DFS |
0216 | Combination Sum III | C++ Python | O(k * 2^9) | O(k) | Medium | ||
0254 | Factor Combinations | C++ Python | O(nlogn) | O(logn) | Medium | 🔒 | |
0267 | Palindrome Permutation II | C++ Python | O(n * n!) | O(n) | Medium | 🔒 | |
0291 | Word Pattern II | C++ Python | O(n * C(n - 1, c - 1)) | O(n + c) | Hard | 🔒 | |
0294 | Flip Game II | C++ Python | O(n + c^2) | O(c) | Medium | 🔒 | DP, Hash |
0320 | Generalized Abbreviation | C++ Python | O(n * 2^n) | O(n) | Medium | 🔒 | |
0425 | Word Squares | C++ Python | O(n^2 * n!) | O(n^2) | Hard | 🔒 | |
0526 | Beautiful Arrangement | C++ Python | O(n!) | O(n) | Medium | ||
0676 | Implement Magic Dictionary | C++ Python | O(n) | O(d) | Medium | Trie, DFS | |
0679 | 24 Game | C++ Python | O(1) | O(1) | Hard | DFS | |
0698 | Partition to K Equal Sum Subsets | C++ Python | O(n * 2^n) | O(2^n) | Medium | DFS, DP, Memoization | |
0718 | Maximum Length of Repeated Subarray | C++ Python | O(m * n) | O(min(m, n)) | Medium | DP, Hash, Binary Search | |
0784 | Letter Case Permutation | C++ Python | O(n * 2^n) | O(1) | Easy | ||
0996 | Number of Squareful Arrays | C++ Python | O(n!) | O(n^2) | Hard | ||
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 |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
xxxx | [Coins in a Line] | Python | Medium | ||||
xxxx | [Max Sum Rectangle in 2d Matrix] | Python | Medium | ||||
LCP 13 | 寻宝 | Python | O(ms + m^2*o + 2^m * m^2) | O(s + bs + 2^m*m) | Hard | Review | DP, BFS, Bit Mask, Status Compression |
0010 | Regular Expression Matching | Python | O(m * n) | O(n) | Hard | Review | |
0044 | Wildcard Matching | Python | O(m * n) | O(1) | Hard | Greedy | |
0053 | Maximum Subarray | Python | O(n) | O(1) | Medium | ||
0062 | Unique Paths | Python | O(min(m,n)) | O(1) | Medium | combination | |
0063 | Unique Paths II | Python | O(m * n) | O(min(m,n)) | Medium | ||
0064 | Minimum Path Sum | Python | O(m * n) | O(n) | Medium | ||
0070 | Climbing Stairs | C++ Python | O(logn) | O(1) | Easy | Matrix Exponentiation, Fibonacci | |
0072 | Edit Distance | Python | O(m * n) | O(m + n) | Hard | ||
0087 | Scramble String | Python | O(n^4) | O(n^3) | Hard | ||
0091 | Decode Ways | C++ Python | O(n) | O(1) | Medium | ||
0096 | Unique Binary Search Trees | Python | O(n) | O(1) | Medium | Math, Catalan | |
0097 | Interleaving String | Python | O(m * n) | O(m + n) | Hard | ||
0115 | Distinct Subsequences | Python | O(n^2) | O(n) | Hard | ||
0120 | Triangle | Python | O(m * n) | O(n) | Medium | ||
0123 | Best Time to Buy and Sell Stock III | Python | O(n) | O(1) | Hard | ||
0132 | Palindrome Partitioning II | Python | O(n^2) | O(n^2) | Hard | ||
0139 do | Word Break | C++ Python | O(n * l^2) | O(n) | Medium | ||
0152 | Maximum Product Subarray | C++ Python | O(n) | O(1) | Medium | ||
0174 do | Dungeon Game | Python | O(m * n) | O(m + n) | Hard | ||
0188 do | Best Time to Buy and Sell Stock IV | C++ Python | O(n) | O(n) | Hard | Quick Select, Mono Stack | |
0198 | House Robber | C++ Python | O(n) | O(1) | Easy | ||
0213 | House Robber II | C++ Python | O(n) | O(1) | Medium | ||
0221 | Maximal Square | C++ Python | O(n^2) | O(n) | Medium | EPI | |
0256 | Paint House | C++ Python | O(n) | O(1) | Medium | 🔒 | |
0265 | Paint House II | C++ Python | O(n * k) | O(k) | Hard | 🔒 | |
0276 | Paint Fence | C++ Python | O(n) | O(1) | Easy | 🔒 | |
0279 | Perfect Squares | C++ Python | O(n * sqrt(n)) | O(n) | Medium | Hash | |
0303 | Range Sum Query - Immutable | C++ Python | ctor: O(n), lookup: O(1) | O(n) | Easy | ||
0304 | Range Sum Query 2D - Immutable | C++ Python | ctor: O(m * n), lookup: O(1) | O(m * n) | Medium | ||
0309 | Best Time to Buy and Sell Stock with Cooldown | C++ Python | O(n) | O(1) | Medium | ||
0312 | Burst Balloons | C++ Python | O(n^3) | O(n^2) | Hard | ||
0322 | Coin Change | C++ Python | O(n * k) | O(k) | Medium | ||
0351 | Android Unlock Patterns | C++ Python | O(9^2 * 2^9) | O(9 * 2^9) | Medium | 🔒 | Backtracking |
0357 | Count Numbers with Unique Digits | C++ Python | O(n) | O(1) | Medium | Backtracking, Math | |
0361 | Bomb Enemy | C++ Python | O(m * n) | O(m * n) | Medium | 🔒 | |
0368 | Largest Divisible Subset | C++ Python | O(n^2) | O(n) | Medium | ||
0375 | Guess Number Higher or Lower II | C++ Python | O(n^2) | O(n^2) | Medium | ||
0377 | Combination Sum IV | C++ Python | O(nlogn + n * t) | O(t) | Medium | ||
0403 | Frog Jump | C++ Python | O(n^2) | O(n^2) | Hard | ||
0416 | Partition Equal Subset Sum | C++ Python | O(n * s) | O(s) | Medium | ||
0418 | Sentence Screen Fitting | C++ Python | O(r + n * c) | O(n) | Medium | 🔒 | |
0446 | Arithmetic Slices II - Subsequence | C++ Python | O(n^2) | O(n * d) | Hard | ||
0465 | Optimal Account Balancing | C++ Python | O(n * 2^n) | O(2^n) | Hard | 🔒 | |
0466 | Count The Repetitions | C++ Python | O(s1 * min(s2, n1)) | O(s2) | Hard | ||
0467 | Unique Substrings in Wraparound String | C++ Python | O(n) | O(1) | Medium | ||
0471 | Encode String with Shortest Length | C++ Python | O(n^3) on average | O(n^2) | Medium | 🔒 | |
0472 | Concatenated Words | C++ Python | O(n * l^2) | O(n * l) | Medium | ||
0474 | Ones and Zeroes | C++ Python | O(s * m * n) | O(m * n) | Medium | ||
0486 | Predict the Winner | C++ Python | O(n^2) | O(n) | Medium | Review | |
0509 | Fibonacci Number | C++ Python | O(logn) | O(1) | Easy | variant of Climbing Stairs | Matrix Exponentiation |
0514 | Freedom Trail | C++ Python | O(k) ~ O(k * r^2) | O(r) | Hard | ||
0516 | Longest Palindromic Subsequence | C++ Python | O(n^2) | O(n) | Medium | ||
0546 | Remove Boxes | C++ Python | O(n^3) ~ O(n^4) | O(n^3) | Hard | Review | |
0552 | Student Attendance Record II | C++ Python | O(n) | O(1) | Hard | ||
0562 | Longest Line of Consecutive One in Matrix | C++ Python | O(m * n) | O(n) | Medium | 🔒 | |
0568 | Maximum Vacation Days | C++ Python | O(n^2 * k) | O(n) | Hard | 🔒 | |
0576 | Out of Boundary Paths | C++ Python | O(N * m * n) | O(m * n) | Medium | ||
0583 | Delete Operation for Two Strings | C++ Python | O(m * n) | O(n) | Medium | ||
0600 | Non-negative Integers without Consecutive Ones | C++ Python | O(1) | O(1) | Hard | ||
0629 | K Inverse Pairs Array | C++ Python | O(n * k) | O(k) | Hard | ||
0639 | Decode Ways II | C++ Python | O(n) | O(1) | Hard | ||
0650 | 2 Keys Keyboard | C++ Python | O(sqrt(n)) | O(1) | Medium | ||
0656 | Coin Path | C++ Python | O(n * B) | O(n) | Hard | 🔒 | |
0664 | Strange Printer | C++ Python | O(n^3) | O(n^2) | Hard | ||
0673 | Number of Longest Increasing Subsequence | C++ Python | O(n^2) | O(n) | Medium | ||
0688 | Knight Probability in Chessboard | C++ Python | O(k * n^2) | O(n^2) | Medium | ||
0689 | Maximum Sum of 3 Non-Overlapping Subarrays | C++ Python | O(n) | O(n) | Hard | Double Scan | |
0691 | Stickers to Spell Word | C++ Python | O(T * S^T) | O(T * S^T) | Hard | Backtracking, Memoization | |
0712 | Minimum ASCII Delete Sum for Two Strings | C++ Python | O(m * n) | O(n) | Medium | ||
0714 | Best Time to Buy and Sell Stock with Transaction Fee | C++ Python | O(n) | O(1) | Medium | ||
0727 do | Minimum Window Subsequence | C++ Python | O(s * t) | O(s) | Hard | 🔒 | |
0730 | Count Different Palindromic Subsequences | C++ Python | O(n^2) | O(n) | Hard | ||
0740 | Delete and Earn | C++ Python | O(n) | O(1) | Medium | ||
0741 | Cherry Pickup | C++ Python | O(n^3) | O(n^2) | Hard | ||
0746 | Min Cost Climbing Stairs | C++ Python | O(n) | O(1) | Easy | ||
0750 | Number Of Corner Rectangles | C++ Python | O(n * m^2) | O(n * m) | Medium | ||
0764 | Largest Plus Sign | C++ Python | O(n^2) | O(n^2) | Medium | Double Scan | |
0788 | Rotated Digits | C++ Python | O(logn) | O(logn) | Easy | Memoization | |
0790 | Domino and Tromino Tiling | C++ Python | O(logn) | O(1) | Medium | Matrix Exponentiation | |
0799 | Champagne Tower | C++ Python | O(n^2) | O(n) | Medium | ||
0801 | Minimum Swaps To Make Sequences Increasing | C++ Python | O(n) | O(1) | Medium | ||
0805 | Split Array With Same Average | C++ Python | O(n^4) | O(n^3) | Hard | ||
0808 | Soup Servings | C++ Python | O(1) | O(1) | Medium | Memoization | |
0813 | Largest Sum of Averages | C++ Python | O(k * n^2) | O(n) | Medium | ||
0818 | Race Car | C++ Python | O(nlogn) | O(n) | Hard | ||
0823 | Binary Trees With Factors | C++ Python | O(n^2) | O(n) | Medium | ||
0837 | New 21 Game | C++ Python | O(n) | O(n) | Medium | ||
0838 | Push Dominoes | C++ Python | O(n) | O(n) | Medium | ||
0847 | Shortest Path Visiting All Nodes | C++ Python | O(n *2^n) | O(n * 2^n) | Hard | BFS | |
0877 | Stone Game | C++ Python | O(n^2) | O(n) | Medium | variant of Predict the Winner | |
0879 | Profitable Schemes | C++ Python | O(n * p * g) | O(p * g) | Hard | ||
0903 | Valid Permutations for DI Sequence | C++ Python | O(n^2) | O(n) | Hard | 2D Dynamic Programming | |
0920 | Number of Music Playlists | C++ Python | O(n * l) | O(l) | Hard | ||
0926 | Flip String to Monotone Increasing | C++ Python | O(n) | O(1) | Medium | ||
0931 | Minimum Falling Path Sum | C++ Python | O(n^2) | O(1) | Medium | ||
0935 | Knight Dialer | C++ Python | O(logn) | O(1) | Medium | Matrix Exponentiation | |
0940 | Distinct Subsequences II | C++ Python | O(n) | O(1) | Hard | ||
0943 | Find the Shortest Superstring | C++ Python | O(n^2 * (l^2 + 2^n)) | O(n^2) | Hard | ||
0956 | Tallest Billboard | C++ Python | O(n * 3^(n/2)) | O(3^(n/2)) | Hard | ||
0960 | Delete Columns to Make Sorted III | C++ Python | O(n * l^2) | O(l) | Hard | ||
0964 | Least Operators to Express Number | C++ Python | O(logn / logx) | O(logn) | Hard | Math | |
0975 | Odd Even Jump | C++ Python | O(nlogn) | O(n) | Hard | Mono Stack, BST | |
0980 | Unique Paths III | C++ Python | O((m * n) * 2^(m * n)) | O((m * n) * 2^(m * n)) | Hard | ||
0983 | Minimum Cost For Tickets | C++ Python | O(n) | O(1) | Medium | Review | |
1000 | Minimum Cost to Merge Stones | C++ Python | O(n^3 / k) | O(n^2) | Hard | ||
1027 | Longest Arithmetic Sequence | C++ Python | O(n^2) | O(n^2) | Medium | ||
1035 | Uncrossed Lines | C++ Python | O(m * n) | O(min(m, n)) | Medium | ||
1039 | Minimum Score Triangulation of Polygon | C++ Python | O(n^3) | O(n^2) | Medium | ||
1043 | Partition Array for Maximum Sum | C++ Python | O(n * k) | O(k) | Medium | ||
1048 | Longest String Chain | C++ Python | O(n * l^2) | O(n * l) | Medium | ||
1049 | Last Stone Weight II | C++ Python | O(2^n) | O(2^n) | Medium | ||
1066 | Campus Bikes II | C++ Python | O(w * b * 2^b) | O(w * b * 2^b) | Medium | 🔒 | |
1092 | Shortest Common Supersequence | C++ Python | O(m * n) | O(m * n) | Hard | ||
1105 | Filling Bookcase Shelves | C++ Python | O(n^2) | O(n) | Medium | ||
1125 | Smallest Sufficient Team | C++ Python | O(m * 2^n) | O(2^n) | Hard | ||
1137 | N-th Tribonacci Number | C++ Python | O(logn) | O(1) | Easy | variant of Fibonacci Number | Matrix Exponentiation |
1139 | Largest 1-Bordered Square | C++ Python | O(n^3) | O(n^2) | Medium | 01matrix | |
1140 | Stone Game II | C++ Python | O(n*(logn)^2) | O(nlogn) | Medium | ||
1143 | Longest Common Subsequence LCS2 | C++ Python | O(m * n) | O(min(m, n)) | Medium | ||
1155 | Number of Dice Rolls With Target Sum | C++ Python | O(d * f * t) | O(t) | Medium | steps | |
1182 | Shortest Distance to Target Color | C++ Python | O(n) | O(n) | Medium | 🔒 | |
1186 | Maximum Subarray Sum with One Deletion | C++ Python | O(n) | O(1) | Medium | Kadane's | |
1187 | Make Array Strictly Increasing | C++ Python | O(n^2 * logn) | O(n) | Hard | LISeq | |
1191 | K-Concatenation Maximum Sum | C++ Python | O(n) | O(1) | Medium | Kadane's | |
1216 | Valid Palindrome III | C++ Python | O(n^2) | O(n) | Hard | 🔒, variant of Longest Palindromic Subsequence | |
1218 | Longest Arithmetic Subsequence of Given Difference | C++ Python | O(n) | O(n) | Medium | ||
1220 | Count Vowels Permutation | C++ Python | O(logn) | O(1) | Hard | Matrix Exponentiation, steps | |
1223 | Dice Roll Simulation | C++ Python | O(m * n) | O(m) | Medium | steps | |
1230 | Toss Strange Coins | C++ Python | O(n^2) | O(n) | Medium | ||
1235 | Maximum Profit in Job Scheduling | C++ Python | O(nlogn) | O(n) | Hard | Review | DP, Heap, interval |
1239 | Maximum Length of a Concatenated String with Unique Characters | C++ Python | O(n) ~ O(2^n) | O(1) ~ O(2^n) | Medium | DP, Bit Manipulation | |
1246 | Palindrome Removal | C++ Python | O(n^3) | O(n^2) | Hard | ||
1262 | Greatest Sum Divisible by Three | C++ Python | O(n) | O(1) | Medium | ||
1269 | Number of Ways to Stay in the Same Place After Some Steps | C++ Python | O(n^2) | O(n) | Hard | steps | |
1277 | Count Square Submatrices with All Ones | C++ Python | O(m * n) | O(1) | Medium | 01matrix | |
1278 | Palindrome Partitioning III | C++ Python | O(k * n^2) | O(n^2) | Hard | ||
1289 | Minimum Falling Path Sum II | C++ Python | O(m * n) | O(1) | Hard | ||
1292 | Maximum Side Length of a Square with Sum Less than or Equal to Threshold | C++ Python | O(m * n * log(min(m, n))) | O(m * n) | Medium | block sum, Binary Search | |
1301 | Number of Paths with Max Score | C++ Python | O(n^2) | O(n) | Hard | ||
1312 | Minimum Insertion Steps to Make a String Palindrome | C++ Python | O(n^2) | O(n) | Hard | variant of Longest Common Subsequence | |
1314 | Matrix Block Sum | C++ Python | O(m * n) | O(m * n) | Medium | variant of Range Sum Query 2D - Immutable | block sum |
1320 | Minimum Distance to Type a Word Using Two Fingers | C++ Python | O(n) | O(1) | Hard | steps | |
1335 | Minimum Difficulty of a Job Schedule | C++ Python | O(d * n^2) | O(d * n) | Hard | ||
1340 | Jump Game V | C++ Python | O(n) | O(n) | Hard | Sliding Window, Mono Stack, Segment Tree | |
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 |
1387 | Sort Integers by The Power Value | C++ Python | O(n) on average | O(n) | Medium | Quick Select | |
1388 | Pizza With 3n Slices | C++ Python | O(n^2) | O(n) | Hard | variant of House Robber II | |
1395 | Count Number of Teams | C++ Python | O(n^2) | O(1) | Medium | ||
1397 | Find All Good Strings | C++ Python | O(m * n) | O(m) | Hard | KMP Algorithm |
|
1406 | Stone Game III | C++ Python | O(n) | O(1) | Hard | ||
1411 | Number of Ways to Paint N × 3 Grid | C++ Python | O(logn) | O(1) | Hard | Matrix Exponentiation | |
1416 | Restore The Array | C++ Python | O(nlogk) | O(logk) | Hard | ||
1420 | Build Array Where You Can Find The Maximum Exactly K Comparisons | C++ Python | O(n * m * k) | O(m * k) | Hard | ||
1434 | Number of Ways to Wear Different Hats to Each Other | C++ Python | O(h * 2^n) | O(2^n) | Hard | ||
1444 | Number of Ways of Cutting a Pizza | C++ Python | O(m * n * k * (m + n)) | O(m * n * k) | Hard | ||
1449 | Form Largest Integer With Digits That Add up to Target | C++ Python | O(t) | O(t) | Hard | ||
1458 | Max Dot Product of Two Subsequences | C++ Python | O(m * n) | O(min(m, n)) | Hard | ||
1463 | Cherry Pickup II | C++ Python | O(m * n^2) | O(n^2) | Hard | ||
1467 | Probability of a Two Boxes Having The Same Number of Distinct Balls | C++ Python | O(k^3 * n^2) | O(k^2 * n) | Hard | Binomial Coefficients | |
1473 | Paint House III | C++ Python | O(m * t * n^2) | O(t * n) | Hard | ||
1477 | Find Two Non-overlapping Sub-arrays Each With Target Sum | C++ Python | O(n) | O(n) | Medium | ||
1478 | Allocate Mailboxes | C++ Python | O(m * n^2) | O(n) | Hard | DP, Math | |
1494 | Parallel Courses II | C++ Python | O((n * C(c, min(c, k))) * 2^n) | O(2^n) | Hard | Combinations | |
1504 | Count Submatrices With All Ones | C++ Python | O(m * n) | O(n) | Medium | Mono Stack | |
1510 | Stone Game IV | C++ Python | O(n * sqrt(n)) | O(n) | Hard | ||
1524 | Number of Sub-arrays With Odd Sum | C++ Python | O(n) | O(1) | Medium | ||
1531 | String Compression II | C++ Python | O(n^2 * k) | O(n * k) | Hard | ||
1547 | Minimum Cost to Cut a Stick | C++ Python | O(n^3) | O(n^2) | Hard | ||
1548 | The Most Similar Path in a Graph | C++ Python | O(n^ * m) | O(n * m) | Hard | 🔒 | |
1553 | Minimum Number of Days to Eat N Oranges | C++ Python | O((logn)^2) | O((logn)^2) | Hard | ||
1563 | Stone Game V | C++ Python | O(n^2) | O(n^2) | Hard | ||
1569 | Number of Ways to Reorder Array to Get Same BST | C++ Python | O(n^2) | O(n^2) | Hard | DFS | |
1575 | Count All Possible Routes | C++ Python | O(nlogn + n * f) | O(n * f) | Hard | Math | |
1594 | Maximum Non Negative Product in a Matrix | C++ Python | O(m * n) | O(n) | Medium | ||
1595 | Minimum Cost to Connect Two Groups of Points | C++ Python | O(m * n * 2^n) | O(2^n) | Hard | ||
1617 | Count Subtrees With Max Distance Between Cities | C++ Python | O(n^6) | O(n^3) | Hard | Backtracking, Graph | |
1626 | Best Team With No Conflicts | C++ Python | O(nloga) | O(n) | Medium | variant of Longest Increasing Subsequence | Sort, DP, Segment Tree |
1639 | Number of Ways to Form a Target String Given a Dictionary | C++ Python | O(l * (w + n)) | O(n) | Hard | ||
1655 | Distribute Repeating Integers | C++ Python | O(n + m * 3^m) | O(n + 2^m) | Hard |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
0399 do | Evaluate Division | C++ Python | O(e + q) | O(e) | Medium | Floyd-Warshall Algorithm , BFS, Union Find |
|
0765 | Couples Holding Hands | C++ Python | O(n) | O(n) | Hard | Review | Union Find |
0924 | Minimize Malware Spread | C++ Python | O(n^2) | O(n) | Hard | Union Find | |
0928 | Minimize Malware Spread II | C++ Python | O(n^2) | O(n) | Hard | Review | Union Find |
0959 | Regions Cut By Slashes | C++ Python | O(n^2) | O(n^2) | Medium | Union Find | |
0990 | Satisfiability of Equality Equations | C++ Python | O(n) | O(1) | Medium | Union Find | |
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 |
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 do | Remove Max Number of Edges to Keep Graph Fully Traversable | C++ Python | O(n + m) | O(n) | Hard | Union Find | |
1584 do | 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 |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
0587 | Erect the Fence | C++ Python | O(nlogn) | O(n) | Hard | Convex Hull, Monotone Chain |
|
0892 | Surface Area of 3D Shapes | C++ Python | O(n^2) | O(1) | Easy | ||
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 |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
0874 | Walking Robot Simulation | C++ Python | O(n + k) | O(k) | Easy | ||
1138 | Alphabet Board Path | C++ Python | O(n) | O(1) | Medium | ||
1243 | Array Transformation | C++ Python | O(n^2) | O(n) | Easy |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
xxx | [Top K Frequent Words Big File] | Python | Medium | ||||
0146 | LRU Cache | C++ Python | O(1) | O(k) | Hard | OrderedDict | |
0225 | Implement Stack using Queues | C++ Python | push: O(n), pop: O(1), top: O(1) | O(n) | Easy | ||
0173 | Binary Search Tree Iterator | C++ Python | O(1), amortized | O(h) | Medium | Review | |
0284 | Peeking Iterator | C++ Python | O(1) | O(1) | Medium | ||
0348 | Design Tic-Tac-Toe | C++ Python | O(1) | O(n^2) | Medium | 🔒 | |
0353 | Design Snake Game | C++ Python | O(1) | O(s) | Medium | 🔒 | Deque |
0355 | Design Twitter | C++ Python | O(klogu) | O(t + f) | Medium | LintCode | Heap |
0359 | Logger Rate Limiter | C++ Python | O(1), amortized | O(k) | Easy | 🔒 | Deque |
0362 | Design Hit Counter | C++ Python | O(1), amortized | O(k) | Medium | 🔒 | Deque |
0379 | Design Phone Directory | C++ Python | O(1) | O(n) | Medium | 🔒 | |
0380 | Insert Delete GetRandom O(1) | C++ Python | O(1) | O(n) | Hard | ||
0381 | Insert Delete GetRandom O(1) - Duplicates allowed | C++ Python | O(1) | O(n) | Hard | ||
0432 | All O`one Data Structure | C++ Python | O(1) | O(n) | Hard | ||
0460 | LFU Cache | C++ Python | O(1) | O(k) | Hard | ||
0489 | Robot Room Cleaner | C++ Python | O(n) | O(n) | Hard | 🔒 | |
0535 | Encode and Decode TinyURL | C++ Python | O(1) | O(n) | Medium | ||
0588 | Design In-Memory File System | C++ Python | ls: O(l + klogk) mkdir: O(l) addContentToFile: O(l + c) readContentFromFile: O(l + c) |
O(n + s) | Hard | 🔒 | |
0604 | Design Compressed String Iterator | C++ Python | O(1) | O(1) | Easy | 🔒 | |
0631 | Design Excel Sum Formula | C++ Python | set: O((r * c)^2) get: O(1) sum: O((r * c)^2) |
O(r * c) | Hard | 🔒 | |
0635 | Design Log Storage System | C++ Python | put: O(1) retrieve: O(n + dlogd) |
O(n) | Medium | 🔒 | |
0642 | Design Search Autocomplete System | C++ Python | O(p^2) | O(p * t + s) | Hard | 🔒 | |
0715 | Range Module | C++ Python | add: O(n) remove: O(n) query: O(logn) |
O(n) | Hard | ||
0716 | Max Stack | C++ Python | push: O(logn) pop: O(logn) popMax: O(logn) top: O(1) peekMax: O(1) |
O(n) | Easy | ||
0745 | Prefix and Suffix Search | C++ Python | ctor: O(w * l^2) search : O(p + s) |
O(t) | Hard | Trie | |
0900 | RLE Iterator | C++ Python | O(n) | O(1) | Medium | ||
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 |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
0622 | Design Circular Queue | Python | O(1) | O(k) | Easy | Review | |
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 |
---|---|---|---|---|---|---|---|
0192 | Word Frequency | Shell | O(n) | O(k) | Medium | ||
0193 | Valid Phone Numbers | Shell | O(n) | O(1) | Easy | ||
0194 | Transpose File | Shell | O(n^2) | O(n^2) | Medium | ||
0195 | Tenth Line | Shell | O(n) | O(1) | Easy |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
xxx | [Python Method] | Python | |||||
xxx | [Python Iterator hasNext] | Python |