LeetCode解题报告,记录自己的leetcode成长之路
LeetCode solutions, written in python and cpp
pip install -r requirements.txt
python problem.py <leetcode/lintcode> [-l java|cpp|python(default)] [-t]
# 例如(e.g.):
python problem.py https://leetcode.com/problems/online-stock-span/
python problem.py https://www.lintcode.com/problem/92 -l cpp
- 《算法技术手册》/ Algorithms in a Nutshell
- 《STL源码剖析》/ The Annotated STL Sources
- 《算法心得:高效算法的奥秘》/ Hacker's Delight, 2nd Edition
- 《数学之美》(A chinese version book by Doctor Wujun)
- 《编程之美 : 微软技术面试心得》(A chinese version book by Mircosoft Developers)
Status | List | Progress | Notes |
---|---|---|---|
[16%] | leetcode-discuss.md | 9/54 | - |
[21%] | leetcode-contest.md | 14/64 | - |
[44%] | leetcode-75.md | 33/75 | - |
[44%] | leetcode-google.md | 208/471 | 1 vip |
[50%] | leetcode-topics.md | 72/144 | - |
[86%] | leetcode-top-interview-150.md | 130/150 | - |
[89%] | neetcode150.md | 134/150 | - |
[90%] | grind169.md | 153/169 | 1 vip |
[97%] | grind102.md | 99/102 | 1 vip |
[✅] | 9c-advanced.md | 75/93 | 18 vips |
[✅] | 9c-dp.md | 42/45 | 3 vips |
[✅] | blind75.md | 77/77 | - |
[✅] | geekbang.md | 55/55 | - |
[✅] | grind75.md | 75/75 | - |
[✅] | leetcode-top-100-liked.md | 100/100 | - |
[✅] | leetcode101.md | 183/184 | 1 vip |
[🔲] | 9c-basic.md | 14/129 | 3 vips |
[🔲] | 9c-top.md | 5/48 | - |
Solved: 474 problems
- Math
- Probability
- Combinatorics
- Bit Manipulation
- Bitmask
- Simulation
- Design
- Greedy
- Dynamic Programming
- Game Theory
- Binary Search
- Linked List
- Hash Table
- Stack
- Monotonic Stack
- Queue
- Monotonic Queue
- Heap
- Two Pointers
- Sliding Window
- Sorting
- Counting
- Quickselect
- Divide and Conquer
- Breadth-First Search
- Depth-First Search
- Topological Sort
- Shortest Path
- Backtracking
- Line Sweep
- Ordered Set
- Binary Search Tree
- Binary Indexed Tree
- Segment Tree
- Union Find
- Trie
Link | Problem(24) | Solution | Tag | Time | Space | Ref |
---|---|---|---|---|---|---|
Leetcode-415 | Add Strings | c++, python3 | Math | O(N) | O(1) | - |
Leetcode-504 | Base 7 | c++, python3 | Math | O(N) | O(1) | - |
Leetcode-224 | Basic Calculator | c++, python3 | Math | O(N) | O(N) | - |
Leetcode-227 | Basic Calculator II | c++, python3 | Math | O(N) | O(N) | - |
Leetcode-932 | Beautiful Array | c++, python3 | Math | O(N) | O(N) | - |
Leetcode-3274 | Check If Two Chessboard Squares Have The Same Color | c++, python3 | Math | O(1) | O(1) | - |
Leetcode-3280 | Convert Date To Binary | c++, python3 | Math | O(1) | O(1) | - |
Leetcode-204 | Count Primes | c++, python3 | Math | O(NlogN) | O(N) | - |
Leetcode-150 | Evaluate Reverse Polish Notation | c++, python3 | Math | O(N) | O(N) | - |
Leetcode-168 | Excel Sheet Column Title | c++, python3 | Math | O(logN) | O(1) | - |
Leetcode-172 | Factorial Trailing Zeroes | c++, python3 | Math | O(logN) | O(1) | - |
Leetcode-202 | Happy Number | c++, python3 | Math | O(S) | O(1) | - |
Leetcode-973 | K Closest Points To Origin | c++, python3 | Math | O(NlogN) | O(K) | - |
Leetcode-149 | Max Points On A Line | c++, python3 | Math | O(N^2) | O(N) | - |
Leetcode-462 | Minimum Moves To Equal Array Elements II | c++, python3 | Math | O(NlogN) | O(1) | - |
Leetcode-326 | Power Of Three | c++, python3 | Math | O(1) | O(1) | - |
Leetcode-50 | Powx N | c++, python3 | Math | O(logN) | O(1) | - |
Leetcode-836 | Rectangle Overlap | c++, python3 | Math | O(1) | O(1) | - |
Leetcode-189 | Rotate Array | c++, python3 | Math | O(N) | O(1) | - |
Leetcode-48 | Rotate Image | c++, python3 | Math | O(N^2) | O(1) | - |
Leetcode-69 | Sqrtx | c++, python3 | Math | N(logN) | O(1) | - |
Leetcode-633 | Sum Of Square Numbers | c++, python3 | Math | O(N) | O(1) | - |
Leetcode-263 | Ugly Number | c++, python3 | Math | O(k) | O(1) | - |
Leetcode-367 | Valid Perfect Square | c++, python3 | Math | O(logN) | O(1) | - |
Link | Problem(5) | Solution | Tag | Time | Space | Ref |
---|---|---|---|---|---|---|
Leetcode-470 | Implement Rand10 Using Rand7 | c++, python3 | Probability | O(1) | O(1) | - |
Leetcode-380 | Insert Delete Getrandom O1 | c++, python3 | Probability | O(1) | O(N) | - |
Leetcode-382 | Linked List Random Node | c++, python3 | Probability | O(N) | O(1) | - |
Leetcode-528 | Random Pick With Weight | c++, python3 | Probability | O(NlogN) | O(N) | - |
Leetcode-384 | Shuffle An Array | c++, python3 | Probability | O(N) | O(N) | - |
Link | Problem(2) | Solution | Tag | Time | Space | Ref |
---|---|---|---|---|---|---|
Leetcode-3343 | Count Number Of Balanced Permutations | c++, python3 | Combinatorics | O(N^3) | O(N^3) | - |
Leetcode-62 | Unique Paths | c++, python3 | Combinatorics | O(MN) | O(MN) | - |
Link | Problem(17) | Solution | Tag | Time | Space | Ref |
---|---|---|---|---|---|---|
Leetcode-67 | Add Binary | c++, python3 | Bit Manipulation | O(M+N) | O(1) | - |
Leetcode-693 | Binary Number With Alternating Bits | c++, python3 | Bit Manipulation | O(1) | O(1) | - |
Leetcode-338 | Counting Bits | c++, python3 | Bit Manipulation | O(N) | O(1) | - |
Leetcode-287 | Find The Duplicate Number | c++, python3 | Bit Manipulation | O(N) | O(1) | - |
Leetcode-461 | Hamming Distance | c++, python3 | Bit Manipulation | O(1) | O(1) | - |
Leetcode-3283 | Maximum Number Of Moves To Kill All Pawns | c++, python3 | Bit Manipulation | O(2^K * K) | O(2^K * K) | - |
Leetcode-318 | Maximum Product Of Word Lengths | c++, python3 | Bit Manipulation | O(N^2) | O(N) | - |
Leetcode-268 | Missing Number | c++, python3 | Bit Manipulation | O(N) | O(1) | - |
Leetcode-476 | Number Complement | c++, python3 | Bit Manipulation | O(1) | O(1) | - |
Leetcode-191 | Number Of 1 Bits | c++, python3 | Bit Manipulation | O(1) | O(1) | - |
Leetcode-342 | Power Of Four | c++, python3 | Bit Manipulation | O(1) | O(1) | - |
Leetcode-231 | Power Of Two | c++, python3 | Bit Manipulation | O(1) | O(1) | - |
Leetcode-190 | Reverse Bits | c++, python3 | Bit Manipulation | O(1) | O(1) | - |
Leetcode-3276 | Select Cells In Grid With Maximum Score | c++, python3 | Bit Manipulation | O(NM*2^N) | O(2^N) | - |
Leetcode-136 | Single Number | c++, python3 | Bit Manipulation | O(N) | O(1) | - |
Leetcode-260 | Single Number III | c++, python3 | Bit Manipulation | O(N) | O(1) | - |
Leetcode-371 | Sum Of Two Integers | c++, python3 | Bit Manipulation | O(1) | O(1) | - |
Link | Problem(4) | Solution | Tag | Time | Space | Ref |
---|---|---|---|---|---|---|
Leetcode-3283 | Maximum Number Of Moves To Kill All Pawns | c++, python3 | Bitmask | O(2^K * K) | O(2^K * K) | - |
Leetcode-51 | N Queens | c++, python3 | Bitmask | O(N!) | O(N) | - |
Leetcode-52 | N Queens II | c++, python3 | Bitmask | O(N!) | O(N) | - |
Leetcode-3276 | Select Cells In Grid With Maximum Score | c++, python3 | Bitmask | O(NM*2^N) | O(2^N) | - |
Link | Problem(10) | Solution | Tag | Time | Space | Ref |
---|---|---|---|---|---|---|
Leetcode-67 | Add Binary | c++, python3 | Simulation | O(M+N) | O(1) | - |
Leetcode-415 | Add Strings | c++, python3 | Simulation | O(N) | O(1) | - |
Leetcode-566 | Reshape The Matrix | c++, python3 | Simulation | O(MN) | O(1) | - |
Leetcode-874 | Walking Robot Simulation | c++, python3 | Simulation | O(N) | O(K) | - |
Lintcode-849 | Basic Calculator III | c++, python3 | Simulation | O(N) | O(1) | Leetcode-772 |
Lintcode-553 | Bomb Enemy | c++, python3 | Simulation | O(NM) | O(NM) | Leetcode-361 |
Lintcode-366 | Fibonacci | c++, python3 | Simulation | O(N) | O(N) | - |
Lintcode-22 | Flatten List | c++, python3 | Simulation | O(N) | O(N) | - |
Lintcode-39 | Recover Rotated Sorted Array | c++, python3 | Simulation | O(N) | O(1) | - |
Lintcode-637 | Valid Word Abbreviation | c++, python3 | Simulation | O(N) | O(1) | Leetcode-408 |
Link | Problem(19) | Solution | Tag | Time | Space | Ref |
---|---|---|---|---|---|---|
Leetcode-432 | All Oone Data Structure | c++, python3 | Design | O(1) | O(N) | - |
Leetcode-173 | Binary Search Tree Iterator | c++, python3 | Design | O(1) | O(H) | - |
Leetcode-211 | Design Add And Search Words Data Structure | c++, python3 | Design | O(26^k * N) | O(LN) | - |
Leetcode-295 | Find Median From Data Stream | c++, python3 | Design | O(logN) | O(N) | - |
Leetcode-341 | Flatten Nested List Iterator | c++, python3 | Design | O(*1) | O(N) | - |
Leetcode-232 | Implement Queue Using Stacks | c++, python3 | Design | O(*1) | O(N) | - |
Leetcode-225 | Implement Stack Using Queues | c++, python3 | Design | O(N) | O(N) | - |
Leetcode-208 | Implement Trie Prefix Tree | c++, python3 | Design | O(N) | O(L) | - |
Leetcode-380 | Insert Delete Getrandom O1 | c++, python3 | Design | O(1) | O(N) | - |
Leetcode-703 | Kth Largest Element In A Stream | c++, python3 | Design | O(logN) | O(N) | - |
Leetcode-146 | Lru Cache | c++, python3 | Design | O(1) | O(N) | - |
Leetcode-155 | Min Stack | c++, python3 | Design | O(1) | O(N) | - |
Leetcode-304 | Range Sum Query 2D Immutable | c++, python3 | Design | O(*1) | O(MN) | - |
Leetcode-303 | Range Sum Query Immutable | c++, python3 | Design | O(*1) | O(N) | - |
Leetcode-307 | Range Sum Query Mutable | c++, python3 | Design | O(logN) | O(N) | - |
Leetcode-297 | Serialize And Deserialize Binary Tree | c++, python3 | Design | O(N) | O(N) | - |
Leetcode-449 | Serialize And Deserialize Bst | c++, python3 | Design | O(N) | O(H) | - |
Leetcode-981 | Time Based Key Value Store | c++, python3 | Design | O(logN) | O(N) | - |
Lintcode-601 | Flatten 2D Vector | c++, python3 | Design | O(*1) | O(N) | Leetcode-251 |
Link | Problem(25) | Solution | Tag | Time | Space | Ref |
---|---|---|---|---|---|---|
Leetcode-870 | Advantage Shuffle | c++, python3 | Greedy | O(NlogN) | O(N) | - |
Leetcode-455 | Assign Cookies | c++, python3 | Greedy | O(NlogN) | O(1) | - |
Leetcode-122 | Best Time To Buy And Sell Stock II | c++, python3 | Greedy | O(N) | O(1) | - |
Leetcode-714 | Best Time To Buy And Sell Stock With Transaction Fee | c++, python3 | Greedy | O(N) | O(N) | - |
Leetcode-605 | Can Place Flowers | c++, python3 | Greedy | O(N) | O(N) | - |
Leetcode-135 | Candy | c++, python3 | Greedy | O(N) | O(N) | - |
Leetcode-3048 | Earliest Second To Mark Indices I | c++, python3 | Greedy | O(NlogN) | O(N) | - |
Leetcode-134 | Gas Station | c++, python3 | Greedy | O(N) | O(1) | - |
Leetcode-55 | Jump Game | c++, python3 | Greedy | O(N) | O(1) | - |
Leetcode-860 | Lemonade Change | c++, python3 | Greedy | O(N) | O(1) | - |
Leetcode-409 | Longest Palindrome | c++, python3 | Greedy | O(N) | O(N) | - |
Leetcode-769 | Max Chunks To Make Sorted | c++, python3 | Greedy | O(N) | O(1) | - |
Leetcode-3281 | Maximize Score Of Numbers In Ranges | c++, python3 | Greedy | O(NlogN + NlogD) | O(1) | - |
Leetcode-646 | Maximum Length Of Pair Chain | c++, python3 | Greedy | O(NlogN) | O(N) | - |
Leetcode-452 | Minimum Number Of Arrows To Burst Balloons | c++, python3 | Greedy | O(NlogN) | O(1) | - |
Leetcode-435 | Non Overlapping Intervals | c++, python3 | Greedy | O(NlogN) | O(1) | - |
Leetcode-763 | Partition Labels | c++, python3 | Greedy | O(N) | O(N) | - |
Leetcode-3282 | Reach End Of Array With Max Score | c++, python3 | Greedy | O(N) | O(1) | - |
Leetcode-621 | Task Scheduler | c++, python3 | Greedy | O(N) | O(1) | - |
Leetcode-680 | Valid Palindrome II | c++, python3 | Greedy | O(N) | O(1) | - |
Leetcode-324 | Wiggle Sort II | c++, python3 | Greedy | - | - | - |
Leetcode-376 | Wiggle Subsequence | c++, python3 | Greedy | O(N) | O(N) | - |
Leetcode-44 | Wildcard Matching | c++, python3 | Greedy | O(NM) | O(NM) | - |
Lintcode-3672 | Connecting Cities With Minimum Cost | c++, python3 | Greedy | O(ElogE) | O(E+V) | Leetcode-1135 |
Lintcode-919 | Meeting Rooms II | c++, python3 | Greedy | O(NlogN) | O(N) | Leetcode-253 |
Link | Problem(70) | Solution | Tag | Time | Space | Ref |
---|---|---|---|---|---|---|
Leetcode-542 | 01 Matrix | c++, python3 | Dynamic Programming | O(MN) | O(MN) | - |
Leetcode-650 | 2 Keys Keyboard | c++, python3 | Dynamic Programming | O(NlogN) | O(N) | - |
Leetcode-413 | Arithmetic Slices | c++, python3 | Dynamic Programming | O(N) | O(N) | - |
Leetcode-121 | Best Time To Buy And Sell Stock | c++, python3 | Dynamic Programming | O(N) | O(1) | - |
Leetcode-122 | Best Time To Buy And Sell Stock II | c++, python3 | Dynamic Programming | O(N) | O(1) | - |
Leetcode-123 | Best Time To Buy And Sell Stock III | c++, python3 | Dynamic Programming | O(N) | O(1) | - |
Leetcode-188 | Best Time To Buy And Sell Stock IV | c++, python3 | Dynamic Programming | O(NK) | O(NK) | - |
Leetcode-309 | Best Time To Buy And Sell Stock With Cooldown | c++, python3 | Dynamic Programming | O(N) | O(N) | - |
Leetcode-714 | Best Time To Buy And Sell Stock With Transaction Fee | c++, python3 | Dynamic Programming | O(N) | O(N) | - |
Leetcode-124 | Binary Tree Maximum Path Sum | c++, python3 | Dynamic Programming | O(N) | O(H) | - |
Leetcode-312 | Burst Balloons | c++, python3 | Dynamic Programming | O(N^3) | O(N^2) | - |
Leetcode-787 | Cheapest Flights Within K Stops | c++, python3 | Dynamic Programming | O(ElogV) | O(E+V) | - |
Leetcode-70 | Climbing Stairs | c++, python3 | Dynamic Programming | O(N) | O(1) | - |
Leetcode-322 | Coin Change | c++, python3 | Dynamic Programming | O(K * N) | O(N) | - |
Leetcode-3343 | Count Number Of Balanced Permutations | c++, python3 | Dynamic Programming | O(N^3) | O(N^3) | - |
Leetcode-338 | Counting Bits | c++, python3 | Dynamic Programming | O(N) | O(1) | - |
Leetcode-91 | Decode Ways | c++, python3 | Dynamic Programming | O(N) | O(N) | - |
Leetcode-583 | Delete Operation For Two Strings | c++, python3 | Dynamic Programming | O(MN) | O(MN) | - |
Leetcode-241 | Different Ways To Add Parentheses | c++, python3 | Dynamic Programming | - | - | - |
Leetcode-115 | Distinct Subsequences | c++, python3 | Dynamic Programming | O(NM) | O(NM) | - |
Leetcode-72 | Edit Distance | c++, python3 | Dynamic Programming | O(MN) | O(MN) | - |
Leetcode-403 | Frog Jump | c++, python3 | Dynamic Programming | O(N^2) | O(N^2) | - |
Leetcode-22 | Generate Parentheses | c++, python3 | Dynamic Programming | O(2^N) | O(N) | - |
Leetcode-198 | House Robber | c++, python3 | Dynamic Programming | O(N) | O(N) | - |
Leetcode-213 | House Robber II | c++, python3 | Dynamic Programming | O(N) | O(N) | - |
Leetcode-343 | Integer Break | c++, python3 | Dynamic Programming | O(N) | O(N) | - |
Leetcode-97 | Interleaving String | c++, python3 | Dynamic Programming | O(NM) | O(M) | - |
Leetcode-55 | Jump Game | c++, python3 | Dynamic Programming | O(N) | O(1) | - |
Leetcode-1143 | Longest Common Subsequence | c++, python3 | Dynamic Programming | O(MN) | O(MN) | - |
Leetcode-300 | Longest Increasing Subsequence | c++, python3 | Dynamic Programming | O(N*logN) | O(N) | - |
Leetcode-516 | Longest Palindromic Subsequence | c++, python3 | Dynamic Programming | O(N^2) | O(N^2) | - |
Leetcode-5 | Longest Palindromic Substring | c++, python3 | Dynamic Programming | O(N) | O(N) | - |
Leetcode-32 | Longest Valid Parentheses | c++, python3 | Dynamic Programming | O(N) | O(N) | - |
Leetcode-85 | Maximal Rectangle | c++, python3 | Dynamic Programming | O(NM) | O(M) | - |
Leetcode-221 | Maximal Square | c++, python3 | Dynamic Programming | O(MN) | O(MN) | - |
Leetcode-646 | Maximum Length Of Pair Chain | c++, python3 | Dynamic Programming | O(NlogN) | O(N) | - |
Leetcode-152 | Maximum Product Subarray | c++, python3 | Dynamic Programming | O(N) | O(1) | - |
Leetcode-1235 | Maximum Profit In Job Scheduling | c++, python3 | Dynamic Programming | O(NlogN) | O(N) | - |
Leetcode-53 | Maximum Subarray | c++, python3 | Dynamic Programming | O(N) | O(N) | - |
Leetcode-3277 | Maximum Xor Score Subarray Queries | c++, python3 | Dynamic Programming | O(N^2 + M) | O(N^2) | - |
Leetcode-64 | Minimum Path Sum | c++, python3 | Dynamic Programming | O(MN) | O(MN) | - |
Leetcode-435 | Non Overlapping Intervals | c++, python3 | Dynamic Programming | O(NlogN) | O(1) | - |
Leetcode-474 | Ones And Zeroes | c++, python3 | Dynamic Programming | O(KMN) | O(MN) | - |
Leetcode-132 | Palindrome Partitioning II | c++, python3 | Dynamic Programming | O(N^2) | O(N^2) | - |
Leetcode-647 | Palindromic Substrings | c++, python3 | Dynamic Programming | O(N^2) | O(1) | - |
Leetcode-416 | Partition Equal Subset Sum | c++, python3 | Dynamic Programming | O(N^2) | O(N) | - |
Leetcode-279 | Perfect Squares | c++, python3 | Dynamic Programming | O(NlogN) | O(N) | - |
Leetcode-10 | Regular Expression Matching | c++, python3 | Dynamic Programming | O(MN) | O(MN) | - |
Leetcode-354 | Russian Doll Envelopes | c++, python3 | Dynamic Programming | O(NlogN) | O(N) | - |
Leetcode-87 | Scramble String | c++, python3 | Dynamic Programming | O(N^4) | O(N^3) | - |
Leetcode-3276 | Select Cells In Grid With Maximum Score | c++, python3 | Dynamic Programming | O(NM*2^N) | O(2^N) | - |
Leetcode-313 | Super Ugly Number | c++, python3 | Dynamic Programming | O(NlogK) | O(N+K) | - |
Leetcode-494 | Target Sum | c++, python3 | Dynamic Programming | O(N * Sum) | O(N * Sum) | - |
Leetcode-42 | Trapping Rain Water | c++, python3 | Dynamic Programming | O(N) | O(N) | - |
Leetcode-120 | Triangle | c++, python3 | Dynamic Programming | O(N^2) | O(N) | - |
Leetcode-62 | Unique Paths | c++, python3 | Dynamic Programming | O(MN) | O(MN) | - |
Leetcode-63 | Unique Paths II | c++, python3 | Dynamic Programming | O(NM) | O(NM) | - |
Leetcode-376 | Wiggle Subsequence | c++, python3 | Dynamic Programming | O(N) | O(N) | - |
Leetcode-44 | Wildcard Matching | c++, python3 | Dynamic Programming | O(NM) | O(NM) | - |
Leetcode-139 | Word Break | c++, python3 | Dynamic Programming | O(MN) | O(N) | - |
Lintcode-92 | Backpack | c++, python3 | Dynamic Programming | O(N^2) | O(N^2) | - |
Lintcode-125 | Backpack II | c++, python3 | Dynamic Programming | O(N^2) | O(N^2) | - |
Lintcode-440 | Backpack III | c++, python3 | Dynamic Programming | O(N^2) | O(N^2) | - |
Lintcode-562 | Backpack IV | c++, python3 | Dynamic Programming | O(N^2) | O(N^2) | - |
Lintcode-563 | Backpack V | c++, python3 | Dynamic Programming | O(N^2) | O(N) | - |
Lintcode-437 | Copy Books | c++, python3 | Dynamic Programming | O(N*logP) | O(1) | - |
Lintcode-89 | K Sum | c++, python3 | Dynamic Programming | O(NKT) | O(NKT) | - |
Lintcode-79 | Longest Common Substring | c++, python3 | Dynamic Programming | O(NM) | O(NM) | - |
Lintcode-515 | Paint House | c++, python3 | Dynamic Programming | O(N) | O(N) | Leetcode-256 |
Lintcode-516 | Paint House II | c++, python3 | Dynamic Programming | O(NM) | O(NM) | Leetcode-265 |
Link | Problem(5) | Solution | Tag | Time | Space | Ref |
---|---|---|---|---|---|---|
Leetcode-375 | Guess Number Higher Or Lower II | c++, python3 | Game Theory | O(N^3) | O(N^2) | - |
Leetcode-3283 | Maximum Number Of Moves To Kill All Pawns | c++, python3 | Game Theory | O(2^K * K) | O(2^K * K) | - |
Leetcode-877 | Stone Game | c++, python3 | Game Theory | O(N^2) | O(N^2) | - |
Lintcode-394 | Coins In A Line | c++, python3 | Game Theory | O(N) | O(N) | - |
Lintcode-395 | Coins In A Line II | c++, python3 | Game Theory | O(N) | O(N) | - |
Link | Problem(43) | Solution | Tag | Time | Space | Ref |
---|---|---|---|---|---|---|
Leetcode-704 | Binary Search | c++, python3 | Binary Search | O(logN) | O(1) | - |
Leetcode-3048 | Earliest Second To Mark Indices I | c++, python3 | Binary Search | O(NlogN) | O(N) | - |
Leetcode-1901 | Find A Peak Element II | c++, python3 | Binary Search | O(N * logM) | O(1) | - |
Leetcode-34 | Find First And Last Position Of Element In Sorted Array | c++, python3 | Binary Search | O(logN) | O(1) | - |
Leetcode-658 | Find K Closest Elements | c++, python3 | Binary Search | O(Log(N - K)) | O(1) | - |
Leetcode-153 | Find Minimum In Rotated Sorted Array | c++, python3 | Binary Search | O(logN) | O(1) | - |
Leetcode-154 | Find Minimum In Rotated Sorted Array II | c++, python3 | Binary Search | O(logN) ~ O(N) | O(1) | - |
Leetcode-162 | Find Peak Element | c++, python3 | Binary Search | O(logN) | O(1) | - |
Leetcode-287 | Find The Duplicate Number | c++, python3 | Binary Search | O(N) | O(1) | - |
Leetcode-278 | First Bad Version | c++, python3 | Binary Search | O(logN) | O(1) | - |
Leetcode-374 | Guess Number Higher Or Lower | c++, python3 | Binary Search | O(logN) | O(1) | - |
Leetcode-378 | Kth Smallest Element In A Sorted Matrix | c++, python3 | Binary Search | O(KlogN) | O(N) | - |
Leetcode-2040 | Kth Smallest Product Of Two Sorted Arrays | c++, python3 | Binary Search | O(logA * NlogM) | O(1) | - |
Leetcode-300 | Longest Increasing Subsequence | c++, python3 | Binary Search | O(N*logN) | O(N) | - |
Leetcode-3281 | Maximize Score Of Numbers In Ranges | c++, python3 | Binary Search | O(NlogN + NlogD) | O(1) | - |
Leetcode-2529 | Maximum Count Of Positive Integer And Negative Integer | c++, python3 | Binary Search | O(logN) | O(1) | - |
Leetcode-1235 | Maximum Profit In Job Scheduling | c++, python3 | Binary Search | O(NlogN) | O(N) | - |
Leetcode-4 | Median Of Two Sorted Arrays | c++, python3 | Binary Search | O(log(min(M, N))) | O(1) | - |
Leetcode-209 | Minimum Size Subarray Sum | c++, python3 | Binary Search | O(N) | O(1) | - |
Leetcode-268 | Missing Number | c++, python3 | Binary Search | O(N) | O(1) | - |
Leetcode-1631 | Path With Minimum Effort | c++, python3 | Binary Search | O(NMlogNM) | O(NM) | - |
Leetcode-852 | Peak Index In A Mountain Array | c++, python3 | Binary Search | O(logN) | O(1) | - |
Leetcode-528 | Random Pick With Weight | c++, python3 | Binary Search | O(NlogN) | O(N) | - |
Leetcode-354 | Russian Doll Envelopes | c++, python3 | Binary Search | O(NlogN) | O(N) | - |
Leetcode-74 | Search A 2D Matrix | c++, python3 | Binary Search | O(log(m * n)) | O(1) | - |
Leetcode-240 | Search A 2D Matrix II | c++, python3 | Binary Search | O(M + N) | O(1) | - |
Leetcode-33 | Search In Rotated Sorted Array | c++, python3 | Binary Search | O(logN) | O(1) | - |
Leetcode-81 | Search In Rotated Sorted Array II | c++, python3 | Binary Search | O(logN) ~ O(N) | O(1) | - |
Leetcode-35 | Search Insert Position | c++, python3 | Binary Search | O(logN) | O(1) | - |
Leetcode-540 | Single Element In A Sorted Array | c++, python3 | Binary Search | O(logN) | O(1) | - |
Leetcode-2468 | Split Message Based On Limit | c++, python3 | Binary Search | O(logN + K) | O(1) | - |
Leetcode-69 | Sqrtx | c++, python3 | Binary Search | N(logN) | O(1) | - |
Leetcode-633 | Sum Of Square Numbers | c++, python3 | Binary Search | O(N) | O(1) | - |
Leetcode-981 | Time Based Key Value Store | c++, python3 | Binary Search | O(logN) | O(N) | - |
Leetcode-167 | Two Sum Ii Input Array Is Sorted | c++, python3 | Binary Search | O(N) | O(1) | - |
Leetcode-367 | Valid Perfect Square | c++, python3 | Binary Search | O(logN) | O(1) | - |
Lintcode-457 | Classical Binary Search | c++, python3 | Binary Search | O(logN) | O(1) | - |
Lintcode-437 | Copy Books | c++, python3 | Binary Search | O(N*logP) | O(1) | - |
Lintcode-14 | First Position Of Target | c++, python3 | Binary Search | O(logN) | O(1) | - |
Lintcode-617 | Maximum Average Subarray II | c++, python3 | Binary Search | O(Nlog(A/ε)) | O(N) | Leetcode-644 |
Lintcode-585 | Maximum Number In Mountain Sequence | c++, python3 | Binary Search | O(logN) | O(1) | - |
Lintcode-600 | Smallest Rectangle Enclosing Black Pixels | c++, python3 | Binary Search | O(N * logM + M * logN) | O(1) | Leetcode-302 |
Lintcode-183 | Wood Cut | c++, python3 | Binary Search | O(NlogA) | O(1) | - |
Link | Problem(20) | Solution | Tag | Time | Space | Ref |
---|---|---|---|---|---|---|
Leetcode-432 | All Oone Data Structure | c++, python3 | Linked List | O(1) | O(N) | - |
Leetcode-109 | Convert Sorted List To Binary Search Tree | c++, python3 | Linked List | O(NlogN) | O(logN) | - |
Leetcode-114 | Flatten Binary Tree To Linked List | c++, python3 | Linked List | O(N) | O(H) | - |
Leetcode-160 | Intersection Of Two Linked Lists | c++, python3 | Linked List | O(N) | O(1) | - |
Leetcode-141 | Linked List Cycle | c++, python3 | Linked List | O(N) | O(1) | - |
Leetcode-142 | Linked List Cycle II | c++, python3 | Linked List | O(N) | O(1) | - |
Leetcode-382 | Linked List Random Node | c++, python3 | Linked List | O(N) | O(1) | - |
Leetcode-146 | Lru Cache | c++, python3 | Linked List | O(1) | O(N) | - |
Leetcode-23 | Merge K Sorted Lists | c++, python3 | Linked List | O(NlogK) | O(K) | - |
Leetcode-21 | Merge Two Sorted Lists | c++, python3 | Linked List | O(N) | O(1) | - |
Leetcode-876 | Middle Of The Linked List | c++, python3 | Linked List | O(N) | O(1) | - |
Leetcode-328 | Odd Even Linked List | c++, python3 | Linked List | O(N) | O(1) | - |
Leetcode-234 | Palindrome Linked List | c++, python3 | Linked List | O(N) | O(1) | - |
Leetcode-83 | Remove Duplicates From Sorted List | c++, python3 | Linked List | O(N) | O(1) | - |
Leetcode-19 | Remove Nth Node From End Of List | c++, python3 | Linked List | O(N) | O(1) | - |
Leetcode-206 | Reverse Linked List | c++, python3 | Linked List | O(N) | O(N) | - |
Leetcode-25 | Reverse Nodes In K Group | c++, python3 | Linked List | O(N) | O(1) | - |
Leetcode-148 | Sort List | c++, python3 | Linked List | O(NlogN) | O(logN) | - |
Leetcode-24 | Swap Nodes In Pairs | c++, python3 | Linked List | O(N) | O(1) | - |
Lintcode-1534 | Convert Binary Search Tree To Sorted Doubly Linked List | c++, python3 | Linked List | O(N) | O(H) | - |
Link | Problem(48) | Solution | Tag | Time | Space | Ref |
---|---|---|---|---|---|---|
Leetcode-721 | Accounts Merge | c++, python3 | Hash Table | O(MlogM) | O(N) | - |
Leetcode-432 | All Oone Data Structure | c++, python3 | Hash Table | O(1) | O(N) | - |
Leetcode-106 | Construct Binary Tree From Inorder And Postorder Traversal | c++, python3 | Hash Table | O(N) | O(N) | - |
Leetcode-105 | Construct Binary Tree From Preorder And Inorder Traversal | c++, python3 | Hash Table | O(N) | O(N) | - |
Leetcode-889 | Construct Binary Tree From Preorder And Postorder Traversal | c++, python3 | Hash Table | O(N) | O(N) | - |
Leetcode-217 | Contains Duplicate | c++, python3 | Hash Table | O(N) | O(N) | - |
Leetcode-697 | Degree Of An Array | c++, python3 | Hash Table | O(N) | O(N) | - |
Leetcode-1110 | Delete Nodes And Return Forest | c++, python3 | Hash Table | O(N) | O(N) | - |
Leetcode-438 | Find All Anagrams In A String | c++, python3 | Hash Table | O(N) | O(1) | - |
Leetcode-448 | Find All Numbers Disappeared In An Array | c++, python3 | Hash Table | O(N) | O(1) | - |
Leetcode-49 | Group Anagrams | c++, python3 | Hash Table | O(NL) | O(N) | - |
Leetcode-202 | Happy Number | c++, python3 | Hash Table | O(S) | O(1) | - |
Leetcode-208 | Implement Trie Prefix Tree | c++, python3 | Hash Table | O(N) | O(L) | - |
Leetcode-380 | Insert Delete Getrandom O1 | c++, python3 | Hash Table | O(1) | O(N) | - |
Leetcode-160 | Intersection Of Two Linked Lists | c++, python3 | Hash Table | O(N) | O(1) | - |
Leetcode-205 | Isomorphic Strings | c++, python3 | Hash Table | O(N) | O(N) | - |
Leetcode-141 | Linked List Cycle | c++, python3 | Hash Table | O(N) | O(1) | - |
Leetcode-142 | Linked List Cycle II | c++, python3 | Hash Table | O(N) | O(1) | - |
Leetcode-128 | Longest Consecutive Sequence | c++, python3 | Hash Table | O(N) | O(N) | - |
Leetcode-594 | Longest Harmonious Subsequence | c++, python3 | Hash Table | O(N) | O(N) | - |
Leetcode-409 | Longest Palindrome | c++, python3 | Hash Table | O(N) | O(N) | - |
Leetcode-424 | Longest Repeating Character Replacement | c++, python3 | Hash Table | O(N) | O(N) | - |
Leetcode-3 | Longest Substring Without Repeating Characters | c++, python3 | Hash Table | O(N) | O(N) | - |
Leetcode-146 | Lru Cache | c++, python3 | Hash Table | O(1) | O(N) | - |
Leetcode-169 | Majority Element | c++, python3 | Hash Table | O(N) | O(1) | - |
Leetcode-149 | Max Points On A Line | c++, python3 | Hash Table | O(N^2) | O(N) | - |
Leetcode-76 | Minimum Window Substring | c++, python3 | Hash Table | O(M + N) | O(N) | - |
Leetcode-268 | Missing Number | c++, python3 | Hash Table | O(N) | O(1) | - |
Leetcode-763 | Partition Labels | c++, python3 | Hash Table | O(N) | O(N) | - |
Leetcode-383 | Ransom Note | c++, python3 | Hash Table | O(N) | O(N) | - |
Leetcode-73 | Set Matrix Zeroes | c++, python3 | Hash Table | O(NM) | O(N + M) | - |
Leetcode-480 | Sliding Window Median | c++, python3 | Hash Table | O(NlogK) | O(K) | - |
Leetcode-451 | Sort Characters By Frequency | c++, python3 | Hash Table | O(N) | O(N) | - |
Leetcode-560 | Subarray Sum Equals K | c++, python3 | Hash Table | O(N) | O(N) | - |
Leetcode-572 | Subtree Of Another Tree | c++, python3 | Hash Table | O(NM) | O(H) | - |
Leetcode-37 | Sudoku Solver | c++, python3 | Hash Table | O(N^(N^2)) | O(N) | - |
Leetcode-621 | Task Scheduler | c++, python3 | Hash Table | O(N) | O(1) | - |
Leetcode-981 | Time Based Key Value Store | c++, python3 | Hash Table | O(logN) | O(N) | - |
Leetcode-347 | Top K Frequent Elements | c++, python3 | Hash Table | O(N), O(C*logK) | O(N) | - |
Leetcode-1 | Two Sum | c++, python3 | Hash Table | O(N) | O(N) | - |
Leetcode-653 | Two Sum Iv Input Is A Bst | c++, python3 | Hash Table | O(NH) | O(H) | - |
Leetcode-242 | Valid Anagram | c++, python3 | Hash Table | O(N) | O(1) | - |
Leetcode-36 | Valid Sudoku | c++, python3 | Hash Table | O(N^2) | O(N^2) | - |
Leetcode-874 | Walking Robot Simulation | c++, python3 | Hash Table | O(N) | O(K) | - |
Leetcode-139 | Word Break | c++, python3 | Hash Table | O(MN) | O(N) | - |
Leetcode-126 | Word Ladder II | c++, python3 | Hash Table | O((N*L)^C) | O(N) | - |
Lintcode-138 | Subarray Sum | c++, python3 | Hash Table | O(N) | O(N) | - |
Lintcode-639 | Word Abbreviation | c++, python3 | Hash Table | O(NL) | O(N) | Leetcode-527 |
Link | Problem(20) | Solution | Tag | Time | Space | Ref |
---|---|---|---|---|---|---|
Leetcode-224 | Basic Calculator | c++, python3 | Stack | O(N) | O(N) | - |
Leetcode-227 | Basic Calculator II | c++, python3 | Stack | O(N) | O(N) | - |
Leetcode-173 | Binary Search Tree Iterator | c++, python3 | Stack | O(1) | O(H) | - |
Leetcode-94 | Binary Tree Inorder Traversal | c++, python3 | Stack | O(N) | O(H) | - |
Leetcode-145 | Binary Tree Postorder Traversal | c++, python3 | Stack | O(N) | O(H) | - |
Leetcode-144 | Binary Tree Preorder Traversal | c++, python3 | Stack | O(N) | O(H) | - |
Leetcode-394 | Decode String | c++, python3 | Stack | O(A) | O(A) | - |
Leetcode-150 | Evaluate Reverse Polish Notation | c++, python3 | Stack | O(N) | O(N) | - |
Leetcode-114 | Flatten Binary Tree To Linked List | c++, python3 | Stack | O(N) | O(H) | - |
Leetcode-341 | Flatten Nested List Iterator | c++, python3 | Stack | O(*1) | O(N) | - |
Leetcode-232 | Implement Queue Using Stacks | c++, python3 | Stack | O(*1) | O(N) | - |
Leetcode-225 | Implement Stack Using Queues | c++, python3 | Stack | O(N) | O(N) | - |
Leetcode-897 | Increasing Order Search Tree | c++, python3 | Stack | O(N) | O(H) | - |
Leetcode-32 | Longest Valid Parentheses | c++, python3 | Stack | O(N) | O(N) | - |
Leetcode-155 | Min Stack | c++, python3 | Stack | O(1) | O(N) | - |
Leetcode-1249 | Minimum Remove To Make Valid Parentheses | c++, python3 | Stack | O(N) | O(N) | - |
Leetcode-234 | Palindrome Linked List | c++, python3 | Stack | O(N) | O(1) | - |
Leetcode-20 | Valid Parentheses | c++, python3 | Stack | O(N) | O(N) | - |
Lintcode-849 | Basic Calculator III | c++, python3 | Stack | O(N) | O(1) | Leetcode-772 |
Lintcode-859 | Max Stack | c++, python3 | Stack | - | O(N) | Leetcode-716 |
Link | Problem(6) | Solution | Tag | Time | Space | Ref |
---|---|---|---|---|---|---|
Leetcode-739 | Daily Temperatures | c++, python3 | Monotonic Stack | O(N) | O(N) | - |
Leetcode-84 | Largest Rectangle In Histogram | c++, python3 | Monotonic Stack | O(N) | O(N) | - |
Leetcode-769 | Max Chunks To Make Sorted | c++, python3 | Monotonic Stack | O(N) | O(1) | - |
Leetcode-85 | Maximal Rectangle | c++, python3 | Monotonic Stack | O(NM) | O(M) | - |
Leetcode-503 | Next Greater Element II | c++, python3 | Monotonic Stack | O(N) | O(N) | - |
Leetcode-42 | Trapping Rain Water | c++, python3 | Monotonic Stack | O(N) | O(N) | - |
Link | Problem(3) | Solution | Tag | Time | Space | Ref |
---|---|---|---|---|---|---|
Leetcode-341 | Flatten Nested List Iterator | c++, python3 | Queue | O(*1) | O(N) | - |
Leetcode-232 | Implement Queue Using Stacks | c++, python3 | Queue | O(*1) | O(N) | - |
Leetcode-225 | Implement Stack Using Queues | c++, python3 | Queue | O(N) | O(N) | - |
Link | Problem(1) | Solution | Tag | Time | Space | Ref |
---|---|---|---|---|---|---|
Leetcode-239 | Sliding Window Maximum | c++, python3 | Monotonic Queue | O(N) | O(K) | - |
Link | Problem(24) | Solution | Tag | Time | Space | Ref |
---|---|---|---|---|---|---|
Leetcode-787 | Cheapest Flights Within K Stops | c++, python3 | Heap | O(ElogV) | O(E+V) | - |
Leetcode-3286 | Find A Safe Walk Through A Grid | c++, python3 | Heap | O(NlogN) | O(N) | - |
Leetcode-658 | Find K Closest Elements | c++, python3 | Heap | O(Log(N - K)) | O(1) | - |
Leetcode-295 | Find Median From Data Stream | c++, python3 | Heap | O(logN) | O(N) | - |
Leetcode-3341 | Find Minimum Time To Reach Last Room I | c++, python3 | Heap | O(NMlog(NM)) | O(NM) | - |
Leetcode-3342 | Find Minimum Time To Reach Last Room II | c++, python3 | Heap | O(NMlog(NM)) | O(NM) | - |
Leetcode-973 | K Closest Points To Origin | c++, python3 | Heap | O(NlogN) | O(K) | - |
Leetcode-3275 | K Th Nearest Obstacle Queries | c++, python3 | Heap | O(NlogK) | O(K) | - |
Leetcode-703 | Kth Largest Element In A Stream | c++, python3 | Heap | O(logN) | O(N) | - |
Leetcode-215 | Kth Largest Element In An Array | c++, python3 | Heap | O(N) ~ O(N^2) | O(1) | - |
Leetcode-378 | Kth Smallest Element In A Sorted Matrix | c++, python3 | Heap | O(KlogN) | O(N) | - |
Leetcode-23 | Merge K Sorted Lists | c++, python3 | Heap | O(NlogK) | O(K) | - |
Leetcode-743 | Network Delay Time | c++, python3 | Heap | O(ElogE) | O(E+V) | - |
Leetcode-1514 | Path With Maximum Probability | c++, python3 | Heap | O(VlogE) | O(V+E) | - |
Leetcode-1631 | Path With Minimum Effort | c++, python3 | Heap | O(NMlogNM) | O(NM) | - |
Leetcode-882 | Reachable Nodes In Subdivided Graph | c++, python3 | Heap | O(ElogE) | O(V+E) | - |
Leetcode-239 | Sliding Window Maximum | c++, python3 | Heap | O(N) | O(K) | - |
Leetcode-480 | Sliding Window Median | c++, python3 | Heap | O(NlogK) | O(K) | - |
Leetcode-451 | Sort Characters By Frequency | c++, python3 | Heap | O(N) | O(N) | - |
Leetcode-621 | Task Scheduler | c++, python3 | Heap | O(N) | O(1) | - |
Leetcode-218 | The Skyline Problem | c++, python3 | Heap | O(NlogN) | O(N) | - |
Leetcode-347 | Top K Frequent Elements | c++, python3 | Heap | O(N), O(C*logK) | O(N) | - |
Leetcode-407 | Trapping Rain Water II | c++, python3 | Heap | O(NlogN) | O(N) | - |
Lintcode-919 | Meeting Rooms II | c++, python3 | Heap | O(NlogN) | O(N) | Leetcode-253 |
Link | Problem(29) | Solution | Tag | Time | Space | Ref |
---|---|---|---|---|---|---|
Leetcode-15 | 3Sum | c++, python3 | Two Pointers | O(N^2) | O(1) | - |
Leetcode-18 | 4Sum | c++, python3 | Two Pointers | O(N^3) | O(1) | - |
Leetcode-870 | Advantage Shuffle | c++, python3 | Two Pointers | O(NlogN) | O(N) | - |
Leetcode-455 | Assign Cookies | c++, python3 | Two Pointers | O(NlogN) | O(1) | - |
Leetcode-696 | Count Binary Substrings | c++, python3 | Two Pointers | O(N) | O(1) | - |
Leetcode-295 | Find Median From Data Stream | c++, python3 | Two Pointers | O(logN) | O(N) | - |
Leetcode-287 | Find The Duplicate Number | c++, python3 | Two Pointers | O(N) | O(1) | - |
Leetcode-28 | Find The Index Of The First Occurrence In A String | c++, python3 | Two Pointers | O(M + N) | O(N) | - |
Leetcode-202 | Happy Number | c++, python3 | Two Pointers | O(S) | O(1) | - |
Leetcode-160 | Intersection Of Two Linked Lists | c++, python3 | Two Pointers | O(N) | O(1) | - |
Leetcode-141 | Linked List Cycle | c++, python3 | Two Pointers | O(N) | O(1) | - |
Leetcode-142 | Linked List Cycle II | c++, python3 | Two Pointers | O(N) | O(1) | - |
Leetcode-5 | Longest Palindromic Substring | c++, python3 | Two Pointers | O(N) | O(N) | - |
Leetcode-524 | Longest Word In Dictionary Through Deleting | c++, python3 | Two Pointers | O(N*logN + M * N) | O(1) | - |
Leetcode-88 | Merge Sorted Array | c++, python3 | Two Pointers | O(M + N) | O(1) | - |
Leetcode-876 | Middle Of The Linked List | c++, python3 | Two Pointers | O(N) | O(1) | - |
Leetcode-234 | Palindrome Linked List | c++, python3 | Two Pointers | O(N) | O(1) | - |
Leetcode-647 | Palindromic Substrings | c++, python3 | Two Pointers | O(N^2) | O(1) | - |
Leetcode-763 | Partition Labels | c++, python3 | Two Pointers | O(N) | O(N) | - |
Leetcode-19 | Remove Nth Node From End Of List | c++, python3 | Two Pointers | O(N) | O(1) | - |
Leetcode-189 | Rotate Array | c++, python3 | Two Pointers | O(N) | O(1) | - |
Leetcode-75 | Sort Colors | c++, python3 | Two Pointers | O(N) | O(1) | - |
Leetcode-148 | Sort List | c++, python3 | Two Pointers | O(NlogN) | O(logN) | - |
Leetcode-633 | Sum Of Square Numbers | c++, python3 | Two Pointers | O(N) | O(1) | - |
Leetcode-42 | Trapping Rain Water | c++, python3 | Two Pointers | O(N) | O(N) | - |
Leetcode-167 | Two Sum Ii Input Array Is Sorted | c++, python3 | Two Pointers | O(N) | O(1) | - |
Leetcode-653 | Two Sum Iv Input Is A Bst | c++, python3 | Two Pointers | O(NH) | O(H) | - |
Leetcode-680 | Valid Palindrome II | c++, python3 | Two Pointers | O(N) | O(1) | - |
Lintcode-386 | Longest Substring With At Most K Distinct Characters | c++, python3 | Two Pointers | O(N) | O(K) | Leetcode-159, 340 |
Link | Problem(10) | Solution | Tag | Time | Space | Ref |
---|---|---|---|---|---|---|
Leetcode-438 | Find All Anagrams In A String | c++, python3 | Sliding Window | O(N) | O(1) | - |
Leetcode-658 | Find K Closest Elements | c++, python3 | Sliding Window | O(Log(N - K)) | O(1) | - |
Leetcode-594 | Longest Harmonious Subsequence | c++, python3 | Sliding Window | O(N) | O(N) | - |
Leetcode-424 | Longest Repeating Character Replacement | c++, python3 | Sliding Window | O(N) | O(N) | - |
Leetcode-3 | Longest Substring Without Repeating Characters | c++, python3 | Sliding Window | O(N) | O(N) | - |
Leetcode-643 | Maximum Average Subarray I | c++, python3 | Sliding Window | O(N) | O(1) | - |
Leetcode-209 | Minimum Size Subarray Sum | c++, python3 | Sliding Window | O(N) | O(1) | - |
Leetcode-76 | Minimum Window Substring | c++, python3 | Sliding Window | O(M + N) | O(N) | - |
Leetcode-239 | Sliding Window Maximum | c++, python3 | Sliding Window | O(N) | O(K) | - |
Leetcode-480 | Sliding Window Median | c++, python3 | Sliding Window | O(NlogK) | O(K) | - |
Link | Problem(33) | Solution | Tag | Time | Space | Ref |
---|---|---|---|---|---|---|
Leetcode-15 | 3Sum | c++, python3 | Sorting | O(N^2) | O(1) | - |
Leetcode-18 | 4Sum | c++, python3 | Sorting | O(N^3) | O(1) | - |
Leetcode-721 | Accounts Merge | c++, python3 | Sorting | O(MlogM) | O(N) | - |
Leetcode-870 | Advantage Shuffle | c++, python3 | Sorting | O(NlogN) | O(N) | - |
Leetcode-455 | Assign Cookies | c++, python3 | Sorting | O(NlogN) | O(1) | - |
Leetcode-217 | Contains Duplicate | c++, python3 | Sorting | O(N) | O(N) | - |
Leetcode-658 | Find K Closest Elements | c++, python3 | Sorting | O(Log(N - K)) | O(1) | - |
Leetcode-295 | Find Median From Data Stream | c++, python3 | Sorting | O(logN) | O(N) | - |
Leetcode-49 | Group Anagrams | c++, python3 | Sorting | O(NL) | O(N) | - |
Leetcode-973 | K Closest Points To Origin | c++, python3 | Sorting | O(NlogN) | O(K) | - |
Leetcode-215 | Kth Largest Element In An Array | c++, python3 | Sorting | O(N) ~ O(N^2) | O(1) | - |
Leetcode-378 | Kth Smallest Element In A Sorted Matrix | c++, python3 | Sorting | O(KlogN) | O(N) | - |
Leetcode-524 | Longest Word In Dictionary Through Deleting | c++, python3 | Sorting | O(N*logN + M * N) | O(1) | - |
Leetcode-769 | Max Chunks To Make Sorted | c++, python3 | Sorting | O(N) | O(1) | - |
Leetcode-3281 | Maximize Score Of Numbers In Ranges | c++, python3 | Sorting | O(NlogN + NlogD) | O(1) | - |
Leetcode-646 | Maximum Length Of Pair Chain | c++, python3 | Sorting | O(NlogN) | O(N) | - |
Leetcode-1235 | Maximum Profit In Job Scheduling | c++, python3 | Sorting | O(NlogN) | O(N) | - |
Leetcode-23 | Merge K Sorted Lists | c++, python3 | Sorting | O(NlogK) | O(K) | - |
Leetcode-88 | Merge Sorted Array | c++, python3 | Sorting | O(M + N) | O(1) | - |
Leetcode-462 | Minimum Moves To Equal Array Elements II | c++, python3 | Sorting | O(NlogN) | O(1) | - |
Leetcode-452 | Minimum Number Of Arrows To Burst Balloons | c++, python3 | Sorting | O(NlogN) | O(1) | - |
Leetcode-268 | Missing Number | c++, python3 | Sorting | O(N) | O(1) | - |
Leetcode-435 | Non Overlapping Intervals | c++, python3 | Sorting | O(NlogN) | O(1) | - |
Leetcode-406 | Queue Reconstruction By Height | c++, python3 | Sorting | O(NlogN) | O(1) | - |
Leetcode-354 | Russian Doll Envelopes | c++, python3 | Sorting | O(NlogN) | O(N) | - |
Leetcode-75 | Sort Colors | c++, python3 | Sorting | O(N) | O(1) | - |
Leetcode-148 | Sort List | c++, python3 | Sorting | O(NlogN) | O(logN) | - |
Leetcode-242 | Valid Anagram | c++, python3 | Sorting | O(N) | O(1) | - |
Leetcode-324 | Wiggle Sort II | c++, python3 | Sorting | - | - | - |
Lintcode-920 | Meeting Rooms | c++, python3 | Sorting | O(NlogN) | O(1) | Leetcode-252 |
Lintcode-919 | Meeting Rooms II | c++, python3 | Sorting | O(NlogN) | O(N) | Leetcode-253 |
Lintcode-39 | Recover Rotated Sorted Array | c++, python3 | Sorting | O(N) | O(1) | - |
Lintcode-508 | Wiggle Sort | c++, python3 | Sorting | O(N) | O(1) | Leetcode-280 |
Link | Problem(7) | Solution | Tag | Time | Space | Ref |
---|---|---|---|---|---|---|
Leetcode-594 | Longest Harmonious Subsequence | c++, python3 | Counting | O(N) | O(N) | - |
Leetcode-169 | Majority Element | c++, python3 | Counting | O(N) | O(1) | - |
Leetcode-2529 | Maximum Count Of Positive Integer And Negative Integer | c++, python3 | Counting | O(logN) | O(1) | - |
Leetcode-383 | Ransom Note | c++, python3 | Counting | O(N) | O(N) | - |
Leetcode-451 | Sort Characters By Frequency | c++, python3 | Counting | O(N) | O(N) | - |
Leetcode-621 | Task Scheduler | c++, python3 | Counting | O(N) | O(1) | - |
Leetcode-347 | Top K Frequent Elements | c++, python3 | Counting | O(N), O(C*logK) | O(N) | - |
Link | Problem(4) | Solution | Tag | Time | Space | Ref |
---|---|---|---|---|---|---|
Leetcode-973 | K Closest Points To Origin | c++, python3 | Quickselect | O(NlogN) | O(K) | - |
Leetcode-215 | Kth Largest Element In An Array | c++, python3 | Quickselect | O(N) ~ O(N^2) | O(1) | - |
Leetcode-347 | Top K Frequent Elements | c++, python3 | Quickselect | O(N), O(C*logK) | O(N) | - |
Leetcode-324 | Wiggle Sort II | c++, python3 | Quickselect | - | - | - |
Link | Problem(21) | Solution | Tag | Time | Space | Ref |
---|---|---|---|---|---|---|
Leetcode-932 | Beautiful Array | c++, python3 | Divide and Conquer | O(N) | O(N) | - |
Leetcode-106 | Construct Binary Tree From Inorder And Postorder Traversal | c++, python3 | Divide and Conquer | O(N) | O(N) | - |
Leetcode-105 | Construct Binary Tree From Preorder And Inorder Traversal | c++, python3 | Divide and Conquer | O(N) | O(N) | - |
Leetcode-889 | Construct Binary Tree From Preorder And Postorder Traversal | c++, python3 | Divide and Conquer | O(N) | O(N) | - |
Leetcode-108 | Convert Sorted Array To Binary Search Tree | c++, python3 | Divide and Conquer | O(N) | O(N) | - |
Leetcode-109 | Convert Sorted List To Binary Search Tree | c++, python3 | Divide and Conquer | O(NlogN) | O(logN) | - |
Leetcode-973 | K Closest Points To Origin | c++, python3 | Divide and Conquer | O(NlogN) | O(K) | - |
Leetcode-215 | Kth Largest Element In An Array | c++, python3 | Divide and Conquer | O(N) ~ O(N^2) | O(1) | - |
Leetcode-169 | Majority Element | c++, python3 | Divide and Conquer | O(N) | O(1) | - |
Leetcode-53 | Maximum Subarray | c++, python3 | Divide and Conquer | O(N) | O(N) | - |
Leetcode-4 | Median Of Two Sorted Arrays | c++, python3 | Divide and Conquer | O(log(min(M, N))) | O(1) | - |
Leetcode-23 | Merge K Sorted Lists | c++, python3 | Divide and Conquer | O(NlogK) | O(K) | - |
Leetcode-191 | Number Of 1 Bits | c++, python3 | Divide and Conquer | O(1) | O(1) | - |
Leetcode-190 | Reverse Bits | c++, python3 | Divide and Conquer | O(1) | O(1) | - |
Leetcode-240 | Search A 2D Matrix II | c++, python3 | Divide and Conquer | O(M + N) | O(1) | - |
Leetcode-148 | Sort List | c++, python3 | Divide and Conquer | O(NlogN) | O(logN) | - |
Leetcode-218 | The Skyline Problem | c++, python3 | Divide and Conquer | O(NlogN) | O(N) | - |
Leetcode-347 | Top K Frequent Elements | c++, python3 | Divide and Conquer | O(N), O(C*logK) | O(N) | - |
Leetcode-324 | Wiggle Sort II | c++, python3 | Divide and Conquer | - | - | - |
Lintcode-1534 | Convert Binary Search Tree To Sorted Doubly Linked List | c++, python3 | Divide and Conquer | O(N) | O(H) | - |
Lintcode-11 | Search Range In Binary Search Tree | c++, python3 | Divide and Conquer | O(N) | O(H) | - |
Link | Problem(34) | Solution | Tag | Time | Space | Ref |
---|---|---|---|---|---|---|
Leetcode-542 | 01 Matrix | c++, python3 | Breadth-First Search | O(MN) | O(MN) | - |
Leetcode-721 | Accounts Merge | c++, python3 | Breadth-First Search | O(MlogM) | O(N) | - |
Leetcode-637 | Average Of Levels In Binary Tree | c++, python3 | Breadth-First Search | O(N) | O(N) | - |
Leetcode-102 | Binary Tree Level Order Traversal | c++, python3 | Breadth-First Search | O(N) | O(Width) | - |
Leetcode-199 | Binary Tree Right Side View | c++, python3 | Breadth-First Search | O(N) | O(W) | - |
Leetcode-322 | Coin Change | c++, python3 | Breadth-First Search | O(K * N) | O(N) | - |
Leetcode-513 | Find Bottom Left Tree Value | c++, python3 | Breadth-First Search | O(N) | O(W) | - |
Leetcode-733 | Flood Fill | c++, python3 | Breadth-First Search | O(NM) | O(NM) | - |
Leetcode-226 | Invert Binary Tree | c++, python3 | Breadth-First Search | O(N) | O(H) | - |
Leetcode-785 | Is Graph Bipartite | c++, python3 | Breadth-First Search | O(E+V) | O(W) | - |
Leetcode-695 | Max Area Of Island | c++, python3 | Breadth-First Search | O(MN) | O(MN) | - |
Leetcode-104 | Maximum Depth Of Binary Tree | c++, python3 | Breadth-First Search | O(N) | O(H) | - |
Leetcode-3283 | Maximum Number Of Moves To Kill All Pawns | c++, python3 | Breadth-First Search | O(2^K * K) | O(2^K * K) | - |
Leetcode-617 | Merge Two Binary Trees | c++, python3 | Breadth-First Search | O(N) | O(H) | - |
Leetcode-530 | Minimum Absolute Difference In Bst | c++, python3 | Breadth-First Search | O(N) | O(H) | - |
Leetcode-111 | Minimum Depth Of Binary Tree | c++, python3 | Breadth-First Search | O(N) | O(W) | - |
Leetcode-200 | Number Of Islands | c++, python3 | Breadth-First Search | O(MN) | O(MN) | - |
Leetcode-547 | Number Of Provinces | c++, python3 | Breadth-First Search | O(N^2) | O(N) | - |
Leetcode-417 | Pacific Atlantic Water Flow | c++, python3 | Breadth-First Search | O(MN) | O(MN) | - |
Leetcode-1631 | Path With Minimum Effort | c++, python3 | Breadth-First Search | O(NMlogNM) | O(NM) | - |
Leetcode-279 | Perfect Squares | c++, python3 | Breadth-First Search | O(NlogN) | O(N) | - |
Leetcode-684 | Redundant Connection | c++, python3 | Breadth-First Search | O(N) | O(1) | - |
Leetcode-994 | Rotting Oranges | c++, python3 | Breadth-First Search | O(NM) | O(NM) | - |
Leetcode-100 | Same Tree | c++, python3 | Breadth-First Search | O(N) | O(H) | - |
Leetcode-297 | Serialize And Deserialize Binary Tree | c++, python3 | Breadth-First Search | O(N) | O(N) | - |
Leetcode-449 | Serialize And Deserialize Bst | c++, python3 | Breadth-First Search | O(N) | O(H) | - |
Leetcode-934 | Shortest Bridge | c++, python3 | Breadth-First Search | O(N^2) | O(N^2) | - |
Leetcode-404 | Sum Of Left Leaves | c++, python3 | Breadth-First Search | O(N) | O(H) | - |
Leetcode-130 | Surrounded Regions | c++, python3 | Breadth-First Search | O(MN) | O(1) | - |
Leetcode-101 | Symmetric Tree | c++, python3 | Breadth-First Search | O(N) | O(H) | - |
Leetcode-407 | Trapping Rain Water II | c++, python3 | Breadth-First Search | O(NlogN) | O(N) | - |
Leetcode-653 | Two Sum Iv Input Is A Bst | c++, python3 | Breadth-First Search | O(NH) | O(H) | - |
Leetcode-126 | Word Ladder II | c++, python3 | Breadth-First Search | O((N*L)^C) | O(N) | - |
Lintcode-178 | Graph Valid Tree | c++, python3 | Breadth-First Search | O(N) | O(N) | LeetCode-261 |
Link | Problem(48) | Solution | Tag | Time | Space | Ref |
---|---|---|---|---|---|---|
Leetcode-721 | Accounts Merge | c++, python3 | Depth-First Search | O(MlogM) | O(N) | - |
Leetcode-637 | Average Of Levels In Binary Tree | c++, python3 | Depth-First Search | O(N) | O(N) | - |
Leetcode-110 | Balanced Binary Tree | c++, python3 | Depth-First Search | O(N) | O(H) | - |
Leetcode-94 | Binary Tree Inorder Traversal | c++, python3 | Depth-First Search | O(N) | O(H) | - |
Leetcode-124 | Binary Tree Maximum Path Sum | c++, python3 | Depth-First Search | O(N) | O(H) | - |
Leetcode-145 | Binary Tree Postorder Traversal | c++, python3 | Depth-First Search | O(N) | O(H) | - |
Leetcode-144 | Binary Tree Preorder Traversal | c++, python3 | Depth-First Search | O(N) | O(H) | - |
Leetcode-199 | Binary Tree Right Side View | c++, python3 | Depth-First Search | O(N) | O(W) | - |
Leetcode-538 | Convert Bst To Greater Tree | c++, python3 | Depth-First Search | O(N) | O(H) | - |
Leetcode-1110 | Delete Nodes And Return Forest | c++, python3 | Depth-First Search | O(N) | O(N) | - |
Leetcode-211 | Design Add And Search Words Data Structure | c++, python3 | Depth-First Search | O(26^k * N) | O(LN) | - |
Leetcode-543 | Diameter Of Binary Tree | c++, python3 | Depth-First Search | O(N) | O(H) | - |
Leetcode-513 | Find Bottom Left Tree Value | c++, python3 | Depth-First Search | O(N) | O(W) | - |
Leetcode-114 | Flatten Binary Tree To Linked List | c++, python3 | Depth-First Search | O(N) | O(H) | - |
Leetcode-341 | Flatten Nested List Iterator | c++, python3 | Depth-First Search | O(*1) | O(N) | - |
Leetcode-733 | Flood Fill | c++, python3 | Depth-First Search | O(NM) | O(NM) | - |
Leetcode-897 | Increasing Order Search Tree | c++, python3 | Depth-First Search | O(N) | O(H) | - |
Leetcode-226 | Invert Binary Tree | c++, python3 | Depth-First Search | O(N) | O(H) | - |
Leetcode-785 | Is Graph Bipartite | c++, python3 | Depth-First Search | O(E+V) | O(W) | - |
Leetcode-230 | Kth Smallest Element In A Bst | c++, python3 | Depth-First Search | O(K) | O(H) | - |
Leetcode-235 | Lowest Common Ancestor Of A Binary Search Tree | c++, python3 | Depth-First Search | O(N) | O(H) | - |
Leetcode-236 | Lowest Common Ancestor Of A Binary Tree | c++, python3 | Depth-First Search | O(N) | O(H) | - |
Leetcode-695 | Max Area Of Island | c++, python3 | Depth-First Search | O(MN) | O(MN) | - |
Leetcode-104 | Maximum Depth Of Binary Tree | c++, python3 | Depth-First Search | O(N) | O(H) | - |
Leetcode-617 | Merge Two Binary Trees | c++, python3 | Depth-First Search | O(N) | O(H) | - |
Leetcode-530 | Minimum Absolute Difference In Bst | c++, python3 | Depth-First Search | O(N) | O(H) | - |
Leetcode-111 | Minimum Depth Of Binary Tree | c++, python3 | Depth-First Search | O(N) | O(W) | - |
Leetcode-200 | Number Of Islands | c++, python3 | Depth-First Search | O(MN) | O(MN) | - |
Leetcode-547 | Number Of Provinces | c++, python3 | Depth-First Search | O(N^2) | O(N) | - |
Leetcode-417 | Pacific Atlantic Water Flow | c++, python3 | Depth-First Search | O(MN) | O(MN) | - |
Leetcode-437 | Path Sum III | c++, python3 | Depth-First Search | O(N^2) | O(H) | - |
Leetcode-1631 | Path With Minimum Effort | c++, python3 | Depth-First Search | O(NMlogNM) | O(NM) | - |
Leetcode-332 | Reconstruct Itinerary | c++, python3 | Depth-First Search | O(ElogE) | O(E+V) | - |
Leetcode-99 | Recover Binary Search Tree | c++, python3 | Depth-First Search | O(N) | O(H) | - |
Leetcode-684 | Redundant Connection | c++, python3 | Depth-First Search | O(N) | O(1) | - |
Leetcode-100 | Same Tree | c++, python3 | Depth-First Search | O(N) | O(H) | - |
Leetcode-297 | Serialize And Deserialize Binary Tree | c++, python3 | Depth-First Search | O(N) | O(N) | - |
Leetcode-449 | Serialize And Deserialize Bst | c++, python3 | Depth-First Search | O(N) | O(H) | - |
Leetcode-934 | Shortest Bridge | c++, python3 | Depth-First Search | O(N^2) | O(N^2) | - |
Leetcode-572 | Subtree Of Another Tree | c++, python3 | Depth-First Search | O(NM) | O(H) | - |
Leetcode-404 | Sum Of Left Leaves | c++, python3 | Depth-First Search | O(N) | O(H) | - |
Leetcode-130 | Surrounded Regions | c++, python3 | Depth-First Search | O(MN) | O(1) | - |
Leetcode-101 | Symmetric Tree | c++, python3 | Depth-First Search | O(N) | O(H) | - |
Leetcode-669 | Trim A Binary Search Tree | c++, python3 | Depth-First Search | O(N) | O(H) | - |
Leetcode-653 | Two Sum Iv Input Is A Bst | c++, python3 | Depth-First Search | O(NH) | O(H) | - |
Leetcode-98 | Validate Binary Search Tree | c++, python3 | Depth-First Search | O(N) | O(H) | - |
Lintcode-11 | Search Range In Binary Search Tree | c++, python3 | Depth-First Search | O(N) | O(H) | - |
Lintcode-634 | Word Squares | c++, python3 | Depth-First Search | O(N * P^5) | O(N) | Leetcode-425 |
Link | Problem(2) | Solution | Tag | Time | Space | Ref |
---|---|---|---|---|---|---|
Leetcode-210 | Course Schedule II | c++, python3 | Topological Sort | O(E+V) | O(E+V) | - |
Leetcode-310 | Minimum Height Trees | c++, python3 | Topological Sort | O(N) | O(N) | - |
Link | Problem(7) | Solution | Tag | Time | Space | Ref |
---|---|---|---|---|---|---|
Leetcode-787 | Cheapest Flights Within K Stops | c++, python3 | Shortest Path | O(ElogV) | O(E+V) | - |
Leetcode-3286 | Find A Safe Walk Through A Grid | c++, python3 | Shortest Path | O(NlogN) | O(N) | - |
Leetcode-3341 | Find Minimum Time To Reach Last Room I | c++, python3 | Shortest Path | O(NMlog(NM)) | O(NM) | - |
Leetcode-3342 | Find Minimum Time To Reach Last Room II | c++, python3 | Shortest Path | O(NMlog(NM)) | O(NM) | - |
Leetcode-743 | Network Delay Time | c++, python3 | Shortest Path | O(ElogE) | O(E+V) | - |
Leetcode-1514 | Path With Maximum Probability | c++, python3 | Shortest Path | O(VlogE) | O(V+E) | - |
Leetcode-882 | Reachable Nodes In Subdivided Graph | c++, python3 | Shortest Path | O(ElogE) | O(V+E) | - |
Link | Problem(14) | Solution | Tag | Time | Space | Ref |
---|---|---|---|---|---|---|
Leetcode-257 | Binary Tree Paths | c++, python3 | Backtracking | O(N) | O(H) | - |
Leetcode-40 | Combination Sum II | c++, python3 | Backtracking | O(2^N) | O(N) | - |
Leetcode-77 | Combinations | c++, python3 | Backtracking | O(k * C(n, k)) | O(K) | - |
Leetcode-22 | Generate Parentheses | c++, python3 | Backtracking | O(2^N) | O(N) | - |
Leetcode-51 | N Queens | c++, python3 | Backtracking | O(N!) | O(N) | - |
Leetcode-52 | N Queens II | c++, python3 | Backtracking | O(N!) | O(N) | - |
Leetcode-113 | Path Sum II | c++, python3 | Backtracking | O(N) | O(H) | - |
Leetcode-46 | Permutations | c++, python3 | Backtracking | O(N!) | O(N) | - |
Leetcode-47 | Permutations II | c++, python3 | Backtracking | O(N!) | O(N) | - |
Leetcode-37 | Sudoku Solver | c++, python3 | Backtracking | O(N^(N^2)) | O(N) | - |
Leetcode-494 | Target Sum | c++, python3 | Backtracking | O(N * Sum) | O(N * Sum) | - |
Leetcode-126 | Word Ladder II | c++, python3 | Backtracking | O((N*L)^C) | O(N) | - |
Leetcode-79 | Word Search | c++, python3 | Backtracking | O(MN*4^L) | O(MN) | - |
Leetcode-212 | Word Search II | c++, python3 | Backtracking | O(NM*4^L) | O(MN + KL) | - |
Link | Problem(3) | Solution | Tag | Time | Space | Ref |
---|---|---|---|---|---|---|
Leetcode-218 | The Skyline Problem | c++, python3 | Line Sweep | O(NlogN) | O(N) | - |
Lintcode-919 | Meeting Rooms II | c++, python3 | Line Sweep | O(NlogN) | O(N) | Leetcode-253 |
Lintcode-391 | Number Of Airplanes In The Sky | c++, python3 | Line Sweep | O(NlogN) | O(N) | - |
Link | Problem(1) | Solution | Tag | Time | Space | Ref |
---|---|---|---|---|---|---|
Leetcode-218 | The Skyline Problem | c++, python3 | Ordered Set | O(NlogN) | O(N) | - |
Link | Problem(19) | Solution | Tag | Time | Space | Ref |
---|---|---|---|---|---|---|
Leetcode-173 | Binary Search Tree Iterator | c++, python3 | Binary Search Tree | O(1) | O(H) | - |
Leetcode-538 | Convert Bst To Greater Tree | c++, python3 | Binary Search Tree | O(N) | O(H) | - |
Leetcode-108 | Convert Sorted Array To Binary Search Tree | c++, python3 | Binary Search Tree | O(N) | O(N) | - |
Leetcode-109 | Convert Sorted List To Binary Search Tree | c++, python3 | Binary Search Tree | O(NlogN) | O(logN) | - |
Leetcode-450 | Delete Node In A Bst | c++, python3 | Binary Search Tree | O(H) | O(H) | - |
Leetcode-897 | Increasing Order Search Tree | c++, python3 | Binary Search Tree | O(N) | O(H) | - |
Leetcode-701 | Insert Into A Binary Search Tree | c++, python3 | Binary Search Tree | O(H) | O(H) | - |
Leetcode-703 | Kth Largest Element In A Stream | c++, python3 | Binary Search Tree | O(logN) | O(N) | - |
Leetcode-230 | Kth Smallest Element In A Bst | c++, python3 | Binary Search Tree | O(K) | O(H) | - |
Leetcode-235 | Lowest Common Ancestor Of A Binary Search Tree | c++, python3 | Binary Search Tree | O(N) | O(H) | - |
Leetcode-530 | Minimum Absolute Difference In Bst | c++, python3 | Binary Search Tree | O(N) | O(H) | - |
Leetcode-99 | Recover Binary Search Tree | c++, python3 | Binary Search Tree | O(N) | O(H) | - |
Leetcode-449 | Serialize And Deserialize Bst | c++, python3 | Binary Search Tree | O(N) | O(H) | - |
Leetcode-669 | Trim A Binary Search Tree | c++, python3 | Binary Search Tree | O(N) | O(H) | - |
Leetcode-653 | Two Sum Iv Input Is A Bst | c++, python3 | Binary Search Tree | O(NH) | O(H) | - |
Leetcode-98 | Validate Binary Search Tree | c++, python3 | Binary Search Tree | O(N) | O(H) | - |
Lintcode-1534 | Convert Binary Search Tree To Sorted Doubly Linked List | c++, python3 | Binary Search Tree | O(N) | O(H) | - |
Lintcode-448 | Inorder Successor In Bst | c++, python3 | Binary Search Tree | O(H) | O(1) | - |
Lintcode-11 | Search Range In Binary Search Tree | c++, python3 | Binary Search Tree | O(N) | O(H) | - |
Link | Problem(3) | Solution | Tag | Time | Space | Ref |
---|---|---|---|---|---|---|
Leetcode-406 | Queue Reconstruction By Height | c++, python3 | Binary Indexed Tree | O(NlogN) | O(1) | - |
Leetcode-307 | Range Sum Query Mutable | c++, python3 | Binary Indexed Tree | O(logN) | O(N) | - |
Leetcode-218 | The Skyline Problem | c++, python3 | Binary Indexed Tree | O(NlogN) | O(N) | - |
Link | Problem(7) | Solution | Tag | Time | Space | Ref |
---|---|---|---|---|---|---|
Leetcode-406 | Queue Reconstruction By Height | c++, python3 | Segment Tree | O(NlogN) | O(1) | - |
Leetcode-307 | Range Sum Query Mutable | c++, python3 | Segment Tree | O(logN) | O(N) | - |
Leetcode-218 | The Skyline Problem | c++, python3 | Segment Tree | O(NlogN) | O(N) | - |
Lintcode-205 | Interval Minimum Number | c++, python3 | Segment Tree | O(NlogN) | O(N) | - |
Lintcode-201 | Segment Tree Build | c++, python3 | Segment Tree | O(N) | O(1) | - |
Lintcode-439 | Segment Tree Build II | c++, python3 | Segment Tree | O(N) | O(1) | - |
Lintcode-203 | Segment Tree Modify | c++, python3 | Segment Tree | O(logN) | O(1) | - |
Link | Problem(13) | Solution | Tag | Time | Space | Ref |
---|---|---|---|---|---|---|
Leetcode-721 | Accounts Merge | c++, python3 | Union Find | O(MlogM) | O(N) | - |
Leetcode-785 | Is Graph Bipartite | c++, python3 | Union Find | O(E+V) | O(W) | - |
Leetcode-128 | Longest Consecutive Sequence | c++, python3 | Union Find | O(N) | O(N) | - |
Leetcode-695 | Max Area Of Island | c++, python3 | Union Find | O(MN) | O(MN) | - |
Leetcode-200 | Number Of Islands | c++, python3 | Union Find | O(MN) | O(MN) | - |
Leetcode-547 | Number Of Provinces | c++, python3 | Union Find | O(N^2) | O(N) | - |
Leetcode-1631 | Path With Minimum Effort | c++, python3 | Union Find | O(NMlogNM) | O(NM) | - |
Leetcode-684 | Redundant Connection | c++, python3 | Union Find | O(N) | O(1) | - |
Leetcode-130 | Surrounded Regions | c++, python3 | Union Find | O(MN) | O(1) | - |
Lintcode-3672 | Connecting Cities With Minimum Cost | c++, python3 | Union Find | O(ElogE) | O(E+V) | Leetcode-1135 |
Lintcode-591 | Connecting Graph III | c++, python3 | Union Find | O(N) | O(N) | - |
Lintcode-178 | Graph Valid Tree | c++, python3 | Union Find | O(N) | O(N) | LeetCode-261 |
Lintcode-434 | Number Of Islands II | c++, python3 | Union Find | O(K) | O(NM + K) | - |
Link | Problem(5) | Solution | Tag | Time | Space | Ref |
---|---|---|---|---|---|---|
Leetcode-211 | Design Add And Search Words Data Structure | c++, python3 | Trie | O(26^k * N) | O(LN) | - |
Leetcode-208 | Implement Trie Prefix Tree | c++, python3 | Trie | O(N) | O(L) | - |
Leetcode-139 | Word Break | c++, python3 | Trie | O(MN) | O(N) | - |
Leetcode-212 | Word Search II | c++, python3 | Trie | O(NM*4^L) | O(MN + KL) | - |
Lintcode-634 | Word Squares | c++, python3 | Trie | O(N * P^5) | O(N) | Leetcode-425 |
Link | Problem(6) | Solution | Tag | Time | Space | Ref |
---|---|---|---|---|---|---|
Leetcode-2210 | Count Hills And Valleys In An Array | c++, python3 | Array | O(N) | O(1) | - |
Leetcode-3285 | Find Indices Of Stable Mountains | c++, python3 | Array | O(N) | O(1) | - |
Leetcode-674 | Longest Continuous Increasing Subsequence | c++, python3 | Array | O(N) | O(1) | - |
Leetcode-665 | Non Decreasing Array | c++, python3 | Array | O(N) | O(1) | - |
Leetcode-238 | Product Of Array Except Self | c++, python3 | Array | O(N) | O(1) | - |
Lintcode-402 | Continuous Subarray Sum | c++, python3 | Array | O(N) | O(N) | - |
Link | Problem(3) | Solution | Tag | Time | Space | Ref |
---|---|---|---|---|---|---|
Leetcode-3340 | Check Balanced String | c++, python3 | String | O(N) | O(1) | - |
Leetcode-796 | Rotate String | c++, python3 | String | O(N) | O(N) | - |
Lintcode-1790 | Rotate String II | c++, python3 | String | O(N) | O(N) | - |
Link | Problem(130) | Solution | Tag | Time | Space | Ref |
---|---|---|---|---|---|---|
Leetcode-16 | 3Sum Closest | c++, python3 | Other | - | - | - |
Leetcode-454 | 4Sum II | c++ | Other | - | - | - |
Leetcode-2 | Add Two Numbers | c++, python3 | Other | - | - | - |
Leetcode-269 | Alien Dictionary | python3 | Other | - | - | - |
Leetcode-561 | Array Partition I | c++ | Other | - | - | - |
Leetcode-844 | Backspace String Compare | c++, python3 | Other | - | - | - |
Leetcode-107 | Binary Tree Level Order Traversal II | c++, python3 | Other | - | - | - |
Leetcode-156 | Binary Tree Upside Down | c++, python3 | Other | - | - | - |
Leetcode-314 | Binary Tree Vertical Order Traversal | c++, python3 | Other | - | - | - |
Leetcode-103 | Binary Tree Zigzag Level Order Traversal | c++, python3 | Other | - | - | - |
Leetcode-859 | Buddy Strings | c++ | Other | - | - | - |
Leetcode-815 | Bus Routes | python3 | Other | - | - | - |
Leetcode-1150 | Check If A Number Is Majority Element In A Sorted Array | c++, python3 | Other | - | - | - |
Leetcode-133 | Clone Graph | c++, python3 | Other | - | - | - |
Leetcode-270 | Closest Binary Search Tree Value | c++, python3 | Other | - | - | - |
Leetcode-39 | Combination Sum | c++, python3 | Other | - | - | - |
Leetcode-377 | Combination Sum IV | c++, python3 | Other | - | - | - |
Leetcode-175 | Combine Two Tables | sql | Other | - | - | - |
Leetcode-829 | Consecutive Numbers Sum | python3 | Other | - | - | - |
Leetcode-11 | Container With Most Water | python3 | Other | - | - | - |
Leetcode-219 | Contains Duplicate II | c++ | Other | - | - | - |
Leetcode-138 | Copy List With Random Pointer | python3 | Other | - | - | - |
Leetcode-38 | Count And Say | python3 | Other | - | - | - |
Leetcode-207 | Course Schedule | c++, python3 | Other | - | - | - |
Leetcode-237 | Delete Node In A Linked List | python3 | Other | - | - | - |
Leetcode-498 | Diagonal Traverse | c++ | Other | - | - | - |
Leetcode-29 | Divide Two Integers | c++, python3 | Other | - | - | - |
Leetcode-271 | Encode And Decode Strings | c++, python3 | Other | - | - | - |
Leetcode-535 | Encode And Decode Tinyurl | python3 | Other | - | - | - |
Leetcode-282 | Expression Add Operators | c++, python3 | Other | - | - | - |
Leetcode-760 | Find Anagram Mappings | python3 | Other | - | - | - |
Leetcode-652 | Find Duplicate Subtrees | c++ | Other | - | - | - |
Leetcode-366 | Find Leaves Of Binary Tree | c++, python3 | Other | - | - | - |
Leetcode-724 | Find Pivot Index | c++ | Other | - | - | - |
Leetcode-277 | Find The Celebrity | c++, python3 | Other | - | - | - |
Leetcode-41 | First Missing Positive | python3 | Other | - | - | - |
Leetcode-387 | First Unique Character In A String | c++, python3 | Other | - | - | - |
Leetcode-251 | Flatten 2D Vector | python3 | Other | - | - | - |
Leetcode-832 | Flipping An Image | python3 | Other | - | - | - |
Leetcode-289 | Game Of Life | python3 | Other | - | - | - |
Leetcode-249 | Group Shifted Strings | c++ | Other | - | - | - |
Leetcode-57 | Insert Interval | c++, python3 | Other | - | - | - |
Leetcode-273 | Integer To English Words | python3 | Other | - | - | - |
Leetcode-12 | Integer To Roman | c++, python3 | Other | - | - | - |
Leetcode-349 | Intersection Of Two Arrays | c++, python3 | Other | - | - | - |
Leetcode-350 | Intersection Of Two Arrays II | c++, python3 | Other | - | - | - |
Leetcode-751 | Ip To Cidr | python3 | Other | - | - | - |
Leetcode-463 | Island Perimeter | python3 | Other | - | - | - |
Leetcode-771 | Jewels And Stones | c++ | Other | - | - | - |
Leetcode-45 | Jump Game II | c++, python3 | Other | - | - | - |
Leetcode-532 | K Diff Pairs In An Array | c++, python3 | Other | - | - | - |
Leetcode-683 | K Empty Slots | c++, python3 | Other | - | - | - |
Leetcode-368 | Largest Divisible Subset | c++, python3 | Other | - | - | - |
Leetcode-747 | Largest Number At Least Twice Of Others | c++ | Other | - | - | - |
Leetcode-17 | Letter Combinations Of A Phone Number | c++, python3 | Other | - | - | - |
Leetcode-359 | Logger Rate Limiter | c++ | Other | - | - | - |
Leetcode-388 | Longest Absolute File Path | c++, python3 | Other | - | - | - |
Leetcode-14 | Longest Common Prefix | c++, python3 | Other | - | - | - |
Leetcode-687 | Longest Univalue Path | c++, python3 | Other | - | - | - |
Leetcode-229 | Majority Element II | c++, python3 | Other | - | - | - |
Leetcode-677 | Map Sum Pairs | c++, python3 | Other | - | - | - |
Leetcode-485 | Max Consecutive Ones | c++ | Other | - | - | - |
Leetcode-654 | Maximum Binary Tree | c++, python3 | Other | - | - | - |
Leetcode-56 | Merge Intervals | c++, python3 | Other | - | - | - |
Leetcode-924 | Minimize Malware Spread | python3 | Other | - | - | - |
Leetcode-928 | Minimize Malware Spread II | python3 | Other | - | - | - |
Leetcode-433 | Minimum Genetic Mutation | c++, python3 | Other | - | - | - |
Leetcode-599 | Minimum Index Sum Of Two Lists | c++ | Other | - | - | - |
Leetcode-163 | Missing Ranges | c++, python3 | Other | - | - | - |
Leetcode-283 | Move Zeroes | c++, python3 | Other | - | - | - |
Leetcode-346 | Moving Average From Data Stream | c++, python3 | Other | - | - | - |
Leetcode-43 | Multiply Strings | c++, python3 | Other | - | - | - |
Leetcode-31 | Next Permutation | c++, python3 | Other | - | - | - |
Leetcode-447 | Number Of Boomerangs | c++, python3 | Other | - | - | - |
Leetcode-323 | Number Of Connected Components In An Undirected Graph | c++, python3 | Other | - | - | - |
Leetcode-933 | Number Of Recent Calls | c++, python3 | Other | - | - | - |
Leetcode-161 | One Edit Distance | c++, python3 | Other | - | - | - |
Leetcode-276 | Paint Fence | c++, python3 | Other | - | - | - |
Leetcode-9 | Palindrome Number | c++, python3 | Other | - | - | - |
Leetcode-336 | Palindrome Pairs | python3 | Other | - | - | - |
Leetcode-131 | Palindrome Partitioning | c++, python3 | Other | - | - | - |
Leetcode-86 | Partition List | c++, python3 | Other | - | - | - |
Leetcode-118 | Pascals Triangle | c++, python3 | Other | - | - | - |
Leetcode-119 | Pascals Triangle II | c++, python3 | Other | - | - | - |
Leetcode-66 | Plus One | c++, python3 | Other | - | - | - |
Leetcode-755 | Pour Water | python3 | Other | - | - | - |
Leetcode-370 | Range Addition | c++, python3 | Other | - | - | - |
Leetcode-157 | Read N Characters Given Read4 | c++, python3 | Other | - | - | - |
Leetcode-26 | Remove Duplicates From Sorted Array | c++, python3 | Other | - | - | - |
Leetcode-27 | Remove Element | c++, python3 | Other | - | - | - |
Leetcode-203 | Remove Linked List Elements | python3 | Other | - | - | - |
Leetcode-143 | Reorder List | python3 | Other | - | - | - |
Leetcode-7 | Reverse Integer | c++, python3 | Other | - | - | - |
Leetcode-92 | Reverse Linked List II | c++, python3 | Other | - | - | - |
Leetcode-344 | Reverse String | c++, python3 | Other | - | - | - |
Leetcode-345 | Reverse Vowels Of A String | c++, python3 | Other | - | - | - |
Leetcode-657 | Robot Return To Origin | python3 | Other | - | - | - |
Leetcode-13 | Roman To Integer | c++, python3 | Other | - | - | - |
Leetcode-61 | Rotate List | python3 | Other | - | - | - |
Leetcode-702 | Search In A Sorted Array Of Unknown Size | c++, python3 | Other | - | - | - |
Leetcode-444 | Sequence Reconstruction | c++, python3 | Other | - | - | - |
Leetcode-773 | Sliding Puzzle | python3 | Other | - | - | - |
Leetcode-311 | Sparse Matrix Multiplication | c++, python3 | Other | - | - | - |
Leetcode-54 | Spiral Matrix | c++, python3 | Other | - | - | - |
Leetcode-8 | String To Integer Atoi | c++, python3 | Other | - | - | - |
Leetcode-246 | Strobogrammatic Number | c++, python3 | Other | - | - | - |
Leetcode-78 | Subsets | c++, python3 | Other | - | - | - |
Leetcode-90 | Subsets II | c++, python3 | Other | - | - | - |
Leetcode-30 | Substring With Concatenation Of All Words | c++, python3 | Other | - | - | - |
Leetcode-228 | Summary Ranges | python3 | Other | - | - | - |
Leetcode-68 | Text Justification | python3 | Other | - | - | - |
Leetcode-170 | Two Sum Iii Data Structure Design | c++, python3 | Other | - | - | - |
Leetcode-929 | Unique Email Addresses | python3 | Other | - | - | - |
Leetcode-288 | Unique Word Abbreviation | c++, python3 | Other | - | - | - |
Leetcode-393 | Utf 8 Validation | c++, python3 | Other | - | - | - |
Leetcode-125 | Valid Palindrome | c++, python3 | Other | - | - | - |
Leetcode-408 | Valid Word Abbreviation | c++, python3 | Other | - | - | - |
Leetcode-286 | Walls And Gates | c++, python3 | Other | - | - | - |
Leetcode-127 | Word Ladder | c++, python3 | Other | - | - | - |
Leetcode-6 | Zigzag Conversion | python3 | Other | - | - | - |
Lintcode-652 | Factorization | c++, python3 | Other | - | - | - |
Lintcode-390 | Find Peak Element II | c++, python3 | Other | - | - | - |
Lintcode-144 | Interleaving Positive And Negative Numbers | c++, python3 | Other | - | - | - |
Lintcode-611 | Knight Shortest Path | c++, python3 | Other | - | - | - |
Lintcode-526 | Load Balancer | c++, python3 | Other | - | - | - |
Lintcode-629 | Minimum Spanning Tree | c++, python3 | Other | - | - | - |
Lintcode-31 | Partition Array | python3 | Other | - | - | - |
Lintcode-618 | Search Graph Nodes | c++, python3 | Other | - | - | - |
Lintcode-382 | Triangle Count | c++, python3 | Other | - | - | - |
Lintcode-598 | Zombie In Matrix | c++, python3 | Other | - | - | - |