- Notifications
You must be signed in to change notification settings - Fork1.6k
🏋️ Python / Modern C++ Solutions of All 3706 LeetCode Problems (Weekly Update)
License
NotificationsYou must be signed in to change notification settings
kamyu104/LeetCode-Solutions
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
- 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 myLintCode,GoogleKickStart,GoogleCodeJamIO repositories.
- For more challenging problem solutions, you can also see myGoogleCodeJam,MetaHackerCup repositories.
- Hope you enjoy the journey of learning data structures and algorithms.
- Notes: "🔒" means your subscription ofLeetCode premium membership is required for reading the question.
- Bit Manipulation
- Array
- String
- Linked List
- Stack
- Queue
- Binary Heap
- Tree
- Hash Table
- Math
- Sort
- Two Pointers
- Recursion
- Binary Search
- Binary Search Tree
- Breadth-First Search
- Depth-First Search
- Backtracking
- Dynamic Programming
- Greedy
- Graph
- Geometry
- Simulation
- Constructive Algorithms
- Design
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
2151 | Maximum Good People Based on Statements | C++Python | O(n^2 * 2^n) | O(1) | Hard | Bitmasks, Brute Force | |
2212 | Maximum Points in an Archery Competition | C++Python | O(n * 2^n) | O(n) | Medium | Bitmasks, Brute Force | |
2220 | Minimum Bit Flips to Convert Number | C++Python | O(logn) | O(1) | Easy | Bit Manipulation | |
2275 | Largest Combination With Bitwise AND Greater Than Zero | C++Python | O(nlogr) | O(logr) | Medium | Bit Manipulation, Freq Table | |
2317 | Maximum XOR After Operations | C++Python | O(n) | O(1) | Medium | Bit Manipulation, Greedy | |
2397 | Maximum Rows Covered by Columns | C++Python | O(m * n + m * C(n, k)) | O(m) | Medium | Bitmasks,Hakmem Item 175 | |
2411 | Smallest Subarrays With Maximum Bitwise OR | C++Python | O(n) | O(1) | Medium | Bitmasks, Hash Table | |
2419 | Longest Subarray With Maximum Bitwise AND | C++Python | O(n) | O(1) | Medium | Bit Manipulation | |
2425 | Bitwise XOR of All Pairings | C++Python | O(n) | O(1) | Medium | Bit Manipulation | |
2429 | Minimize XOR | C++Python | O(logn) | O(1) | Medium | Bit Manipulation, Greedy | |
2505 | Bitwise OR of All Subsequence Sums | C++Python | O(n) | O(1) | Medium | 🔒 | Bit Manipulation |
2527 | Find Xor-Beauty of Array | C++Python | O(n) | O(1) | Medium | Bit Manipulation, Math | |
2595 | Number of Even and Odd Bits | C++Python | O(1) | O(1) | Easy | Bit Manipulation | |
2859 | Sum of Values at Indices With K Set Bits | C++Python | O(C(ceil(log2(n)), k)) | O(1) | Easy | Bitmasks,Hakmem Item 175 | |
2917 | Find the K-or of an Array | C++Python | O(nlogr) | O(1) | Easy | Bit Manipulation | |
2932 | Maximum Strong Pair XOR I | C++Python | O(nlogr) | O(t) | Easy | variant ofMaximum XOR of Two Numbers in an Array | Bit Manipulation, Greedy, Trie, DP, Sort, Two Pointers, Brute Force |
2935 | Maximum Strong Pair XOR II | C++Python | O(nlogr) | O(t) | Hard | variant ofMaximum XOR of Two Numbers in an Array | Bit Manipulation, Greedy, Trie, DP, Sort, Two Pointers |
2980 | Check if Bitwise OR Has Trailing Zeros | C++Python | O(n) | O(1) | Easy | Bit Manipulation | |
2997 | Minimum Number of Operations to Make Array XOR Equal to K | C++Python | O(n) | O(1) | Medium | Bit Manipulation | |
3064 | Guess the Number Using Bitwise Questions I | C++Python | O(logn) | O(1) | Medium | 🔒 | Bit Manipulation |
3094 | Guess the Number Using Bitwise Questions II | C++Python | O(logr) | O(1) | Medium | 🔒 | Bit Manipulation |
3125 | Maximum Number That Makes Result of Bitwise AND Zero | C++Python | O(1) | O(1) | Medium | 🔒 | Bit Manipulation |
3133 | Minimum Array End | C++Python | O(logn) | O(1) | Medium | Bit Manipulation | |
3199 | Count Triplets with Even XOR Set Bits I | C++Python | O(nlogr) | O(1) | Easy | 🔒 | Brute Force, Bit Manipulation, Parity |
3215 | Count Triplets with Even XOR Set Bits II | C++Python | O(nlogr) | O(1) | Medium | 🔒 | Bit Manipulation, Parity |
3226 | Number of Bit Changes to Make Two Integers Equal | C++Python | O(logn) | O(1) | Easy | Bit Manipulation | |
3289 | The Two Sneaky Numbers of Digitville | C++Python | O(n) | O(1) | Easy | Bit Manipulation | |
3304 | Find the K-th Character in String Game I | C++Python | O(n) | O(1) | Easy | Bitmasks | |
3307 | Find the K-th Character in String Game II | C++Python | O(1) | O(1) | Hard | Bitmasks | |
3314 | Construct the Minimum Bitwise Array I | C++Python | O(n) | O(1) | Easy | Bit Manipulation | |
3315 | Construct the Minimum Bitwise Array II | C++Python | O(n) | O(1) | Medium | Bit Manipulation | |
3344 | Maximum Sized Array | C++Python | precompute: O(max_s^(1/5) * log(max_s)) runtime: O(log(max_s)) | O(max_s^(1/5)) | Medium | 🔒 | Precompute, Bitmasks, Combinatorics, Binary Search |
3370 | Smallest Number With All Set Bits | C++Python | O(1) | O(1) | Easy | Bit Manipulation | |
3566 | Partition Array into Two Equal Product Subsets | C++Python | O(n * 2^n) | O(1) | Medium | Bitmasks | |
3632 | Subarrays with XOR at Least K | C++Python | O(nlogr) | O(t) | Hard | 🔒 | Bitmasks, Prefix Sum, Trie |
3646 | Next Special Palindrome Number | C++Python | precompute:O(9 * 2^9 + 16 * p + plogp) runtime:O(logp) | O(p) | Hard | Precompute, Bitmasks, Sort, Binary Search | |
3702 | Longest Subsequence With Non-Zero Bitwise XOR | C++Python | O(n) | O(1) | Medium | Bitmasks |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
2398 | Maximum Number of Robots Within Budget | C++Python | O(n) | O(n) | Hard | Mono Deque, Sliding Window, Two Pointers |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
2054 | Two Best Non-Overlapping Events | C++Python | O(nlogn) | O(n) | Medium | Line Sweep, Heap | |
2163 | Minimum Difference in Sums After Removal of Elements | C++Python | O(nlogn) | O(n) | Hard | Heap, Prefix Sum | |
2208 | Minimum Operations to Halve Array Sum | C++Python | O(nlogn) | O(n) | Medium | Heap | |
2386 | Find the K-Sum of an Array | C++Python | O(nlogn + klogk) | O(n + k) | Hard | BFS, Heap | |
2402 | Meeting Rooms III | C++Python | O(mlogm + n + mlogn) | O(n) | Hard | Heap | |
2462 | Total Cost to Hire K Workers | C++Python | O(c + klogc) | O(c) | Medium | Heap, Two Pointers | |
2519 | Count the Number of K-Big Indices | C++Python | O(nlogk) | O(n) | Hard | 🔒 | Heap, Ordered Set, Sorted List |
2530 | Maximal Score After Applying K Operations | C++Python | O(n + klogn) | O(1) | Medium | Heap, Simulation | |
2558 | Take Gifts From the Richest Pile | C++Python | O(n + klogn) | O(1) | Easy | Heap, Simulation | |
2818 | Apply Operations to Maximize Score | C++Python | O(sqrt(r) + n * (logr + sqrt(r)/log(sqrt(r))) + klogn) | O(sqrt(r) + n) | Hard | Number Theory,Linear Sieve of Eratosthenes , Mono Stack, Greedy, Sort, Heap | |
3066 | Minimum Operations to Exceed Threshold Value II | C++Python | O(nlogn) | O(n) | Medium | Simulation, Heap | |
3080 | Mark Elements on Array by Performing Queries | C++Python | O(q + nlogn) | O(n) | Medium | Hash Table, Heap | |
3092 | Most Frequent IDs | C++Python | O(nlogn) | O(n) | Medium | Heap, BST, Sorted List | |
3256 | Maximum Value Sum by Placing Three Rooks I | C++Python | O(m * n) | O(m + n) | Hard | Heap, Brute Force | |
3257 | Maximum Value Sum by Placing Three Rooks II | C++Python | O(m * n) | O(m + n) | Hard | Heap, Brute Force | |
3275 | K-th Nearest Obstacle Queries | C++Python | O(qlogk) | O(k) | Medium | Heap | |
3684 | Maximize Sum of At Most K Distinct Elements | C++Python | O(nlogk) | O(k) | Easy | Heap, Sort | |
3691 | Maximum Total Subarray Value II | C++Python | O((n + k) * logn) | O(n) | Hard | Heap, Sort, Two Pointers, RMQ, Sparse Table, Segment Tree |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
2003 | Smallest Missing Genetic Value in Each Subtree | C++Python | O(n) | O(n) | Hard | DFS, Stack | |
2096 | Step-By-Step Directions From a Binary Tree Node to Another | C++Python | O(n) | O(h) | Medium | DFS, Stack | |
2179 | Count Good Triplets in an Array | C++Python | O(nlogn) | O(n) | Hard | variant ofCreate Sorted Array through Instructions | BIT, Fenwick Tree |
2196 | Create Binary Tree From Descriptions | C++Python | O(n) | O(n) | Medium | ||
2236 | Root Equals Sum of Children | C++Python | O(1) | O(1) | Easy | Tree | |
2277 | Closest Node to Path in Tree | C++Python | O(n + q) | O(n + q) | Hard | 🔒 | Tree, BFS, Binary Lifting,Tarjan's Offline LCA Algorithm |
2421 | Number of Good Paths | C++Python | O(nlogn) | O(n) | Hard | Sort, Union Find | |
2509 | Cycle Length Queries in a Tree | C++Python | O(q * n) | O(1) | Hard | Tree, LCA | |
2846 | Minimum Edge Weight Equilibrium Queries in a Tree | C++Python | O(r * (n + q)) | O(r * n + q) | Hard | Tree, Binary Lifting,Tarjan's Offline LCA Algorithm | |
3109 | Find the Index of Permutation | C++Python | O(nlogn) | O(n) | 🔒, Medium | variant ofCount of Smaller Numbers After Self | BIT, Fenwick Tree, Combinatorics |
3515 | Shortest Path in a Weighted Tree | C++Python | O(nlogn) | O(n) | Hard | BIT, Fenwick Tree, DFS | |
3553 | Minimum Weighted Subgraph With the Required Paths II | C++Python | O(n + q) | O(n + q) | Hard | Tree, DFS,Tarjan's Offline LCA Algorithm | |
3558 | Number of Ways to Assign Edge Weights I | C++Python | O(n) | O(n) | Medium | Tree, BFS, Combinatorics | |
3559 | Number of Ways to Assign Edge Weights II | C++Python | O(n + q) | O(n + q) | Medium | Tree, DFS,Tarjan's Offline LCA Algorithm , Combinatorics | |
3585 | Find Weighted Median Node in Tree | C++Python | O(n + qlogh) | O(n + q) | Hard | Tree, DFS,Tarjan's Offline LCA Algorithm , Binary Search, Prefix Sum |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
2009 | Minimum Number of Operations to Make Array Continuous | C++Python | O(nlogn) | O(1) | Hard | Two Pointers, Sliding Window | |
2024 | Maximize the Confusion of an Exam | C++Python | O(n) | O(1) | Medium | variant ofLongest Repeating Character Replacement | Sliding Window |
2040 | Kth Smallest Product of Two Sorted Arrays | C++Python | O((m + n) * logr) | O(1) | Hard | Binary Search, Two Pointers | |
2046 | Sort Linked List Already Sorted Using Absolute Values | C++Python | O(n) | O(1) | Medium | 🔒 | Linked List |
2062 | Count Vowel Substrings of a String | C++Python | O(n) | O(1) | Easy | variant ofCount Number of Nice Subarrays | Sliding Window |
2067 | Number of Equal Count Substrings | C++Python | O(n) | O(1) | Medium | 🔒 | Sliding Window |
2090 | K Radius Subarray Averages | C++Python | O(n) | O(1) | Medium | Sliding Window | |
2105 | Watering Plants II | C++Python | O(n) | O(1) | Medium | Simulation | |
2107 | Number of Unique Flavors After Sharing K Candies | C++Python | O(n) | O(n) | Medium | 🔒 | Sliding Window |
2134 | Minimum Swaps to Group All 1's Together II | C++Python | O(n) | O(1) | Medium | Sliding Window | |
2149 | Rearrange Array Elements by Sign | C++Python | O(n) | O(1) | Medium | Two Pointers | |
2161 | Partition Array According to Given Pivot | C++Python | O(n) | O(n) | Medium | Two Pointers | |
2200 | Find All K-Distant Indices in an Array | C++Python | O(n) | O(1) | Easy | Two Pointers | |
2234 | Maximum Total Beauty of the Gardens | C++Python | O(nlogn) | O(1) | Hard | Sort, Prefix Sum, Greedy, Binary Search, Two Pointers | |
2302 | Count Subarrays With Score Less Than K | C++Python | O(n) | O(1) | Hard | Two Pointers, Sliding Window | |
2330 | Valid Palindrome IV | C++Python | O(n) | O(1) | Medium | 🔒 | String, Two Pointers |
2332 | The Latest Time to Catch a Bus | C++Python | O(nlogn + mlogm) | O(1) | Medium | String, Two Pointers | |
2337 | Move Pieces to Obtain a String | C++Python | O(n + m) | O(1) | Medium | String, Two Pointers | |
2348 | Number of Zero-Filled Subarrays | C++Python | O(n) | O(1) | Medium | Two Pointers, Combinatorics | |
2379 | Minimum Recolors to Get K Consecutive Black Blocks | C++Python | O(n) | O(1) | Easy | Sliding Window | |
2393 | Count Strictly Increasing Subarrays | C++Python | O(n) | O(1) | Medium | 🔒 | Two Pointers |
2401 | Longest Nice Subarray | C++Python | O(n) | O(1) | Medium | Sliding Window, Two Pointers | |
2444 | Count Subarrays With Fixed Bounds | C++Python | O(n) | O(1) | Hard | variant ofNumber of Substrings Containing All Three Characters | Two Pointers |
2461 | Maximum Sum of Distinct Subarrays With Length K | C++Python | O(n) | O(k) | Medium | Two Pointers | |
2465 | Number of Distinct Averages | C++Python | O(nlogn) | O(n) | Easy | Two Pointers, Hash Table | |
2511 | Maximum Enemy Forts That Can Be Captured | C++Python | O(n) | O(1) | Easy | Array, Two Pointers | |
2516 | Take K of Each Character From Left and Right | C++Python | O(n) | O(1) | Medium | Sliding Window, Two Pointers | |
2524 | Maximum Frequency Score of a Subarray | C++Python | O(n) | O(n) | Hard | 🔒 | Sliding Window, Two Pointers, Freq Table, Hash Table |
2537 | Count the Number of Good Subarrays | C++Python | O(n) | O(n) | Medium | Sliding Window, Two Pointers | |
2540 | Minimum Common Value | C++Python | O(n) | O(1) | Easy | Two Pointers | |
2555 | Maximize Win From Two Segments | C++Python | O(n) | O(n) | Medium | Two Pointers, Sliding Window, DP | |
2563 | Count the Number of Fair Pairs | C++Python | O(nlogn) | O(1) | Medium | Sort, Two Pointers | |
2570 | Merge Two 2D Arrays by Summing Values | C++Python | O(n) | O(1) | Easy | Two Pointers | |
2609 | Find the Longest Balanced Substring of a Binary String | C++Python | O(n) | O(1) | Easy | String, Two Pointers | |
2653 | Sliding Subarray Beauty | C++Python | O(nlogk) | O(k) | Medium | Sorted List, Ordered Set, Two Pointers | |
2730 | Find the Longest Semi-Repetitive Substring | C++Python | O(n) | O(1) | Medium | Two Pointers | |
2743 | Count Substrings Without Repeating Character | C++Python | O(n) | O(1) | Medium | 🔒, variant ofLongest Substring Without Repeating Characters | Two Pointers, Sliding Window |
2747 | Count Zero Request Servers | C++Python | O(nlogn + mlogm) | O(n + m) | Hard | Sort, Two Pointers, Line Sweep | |
2762 | Continuous Subarrays | C++Python | O(n) | O(1) | Medium | Mono Deque, BST, Ordered Dict, Two Pointers, Sliding Window | |
2763 | Sum of Imbalance Numbers of All Subarrays | C++Python | O(n) | O(n) | Hard | Two Pointers, Sliding Window, Hash Table, Combinatorics | |
2779 | Maximum Beauty of an Array After Applying Operation | C++Python | O(nlogn) | O(1) | Medium | Sort, Two Pointers, Sliding Window | |
2781 | Length of the Longest Valid Substring | C++Python | O((m + n) * l) | O(t) | Hard | Two Pointers, Sliding Window, Trie | |
2799 | Count Complete Subarrays in an Array | C++Python | O(n) | O(n) | Medium | Freq Table, Two Pointers, Sliding Window | |
2824 | Count Pairs Whose Sum is Less than Target | C++Python | O(nlogn) | O(1) | Easy | Sort, Two Pointers | |
2831 | Find the Longest Equal Subarray | C++Python | O(n) | O(n) | Medium | Freq Table, Two Pointers, Sliding Window | |
2838 | Maximum Coins Heroes Can Collect | C++Python | O(nlogn + mlogm) | O(n + m) | Medium | 🔒 | Sort, Two Pointers |
2841 | Maximum Sum of Almost Unique Subarray | C++Python | O(n) | O(n) | Medium | Freq Table, Two Pointers, Sliding Window | |
2875 | Minimum Size Subarray in Infinite Array | C++Python | O(n) | O(1) | Medium | Prefix Sum, Hash Table, Two Pointers, Sliding Window | |
2904 | Shortest and Lexicographically Smallest Beautiful String | C++Python | O(n^2) | O(1) | Medium | Two Pointers, Sliding Window | |
2933 | High-Access Employees | C++Python | O(nlogn) | O(n) | Medium | Sort, Two Pointers, Sliding Window | |
2938 | Separate Black and White Balls | C++Python | O(n) | O(1) | Medium | Two Pointers | |
2953 | Count Complete Substrings | C++Python | O(26 + d * n) | O(26) | Medium | Freq Table, Two Pointers, Sliding Window | |
2958 | Length of Longest Subarray With at Most K Frequency | C++Python | O(n) | O(n) | Medium | Freq Table, Two Pointers, Sliding Window | |
2962 | Count Subarrays Where Max Element Appears at Least K Times | C++Python | O(n) | O(1) | Medium | Two Pointers, Sliding Window | |
2968 | Apply Operations to Maximize Frequency Score | C++Python | O(nlogn) | O(1) | Hard | Sort, Two Pointers, Sliding Window, Prefix Sum, Binary Search | |
2970 | Count the Number of Incremovable Subarrays I | C++Python | O(n) | O(1) | Easy | Two Pointers, Brute Force | |
2972 | Count the Number of Incremovable Subarrays II | C++Python | O(n) | O(1) | Hard | Two Pointers | |
3006 | Find Beautiful Indices in the Given Array I | C++Python | O(n) | O(min(a + b + x + y, n)) | Medium | KMP Algorithm , Binary Search, Two Pointers | |
3008 | Find Beautiful Indices in the Given Array II | C++Python | O(n) | O(min(a + b + x + y, n)) | Hard | KMP Algorithm , Binary Search, Two Pointers | |
3013 | Divide an Array Into Subarrays With Minimum Cost II | C++Python | O(nlogd) | O(d) | Hard | Sliding Window, Heap, Freq Table, Ordered Set, BST, Sorted List | |
3085 | Minimum Deletions to Make String K-Special | C++Python | O(n + 26) | O(n + 26) | Medium | Freq Table, Counting Sort, Two Pointers | |
3090 | Maximum Length Substring With Two Occurrences | C++Python | O(n + 26) | O(26) | Easy | Freq Table, Sliding Window, Two Pointers | |
3095 | Shortest Subarray With OR at Least K I | C++Python | O(n * 30) | O(30) | Easy | Brute Force, Freq Table, Two Pointers | |
3097 | Shortest Subarray With OR at Least K II | C++Python | O(n * 30) | O(30) | Medium | Freq Table, Two Pointers | |
3171 | Find Subarray With Bitwise OR Closest to K | C++Python | O(nlogr) | O(logr) | Hard | variant ofFind a Value of a Mysterious Function Closest to Target | DP, Freq Table, Two Pointers, Sliding Window |
3206 | Alternating Groups I | C++Python | O(n) | O(1) | Easy | Two Pointers, Sliding Window | |
3208 | Alternating Groups II | C++Python | O(n) | O(1) | Medium | Two Pointers, Sliding Window | |
3234 | Count the Number of Substrings With Dominant Ones | C++Python | O(n^(3/2)) | O(1) | Medium | Two Pointers, Sliding Window | |
3254 | Find the Power of K-Size Subarrays I | C++Python | O(n) | O(1) | Medium | Two Pointers, Sliding Window | |
3255 | Find the Power of K-Size Subarrays II | C++Python | O(n) | O(1) | Medium | Two Pointers, Sliding Window | |
3258 | Count Substrings That Satisfy K-Constraint I | C++Python | O(n) | O(1) | Easy | Two Pointers, Sliding Window | |
3261 | Count Substrings That Satisfy K-Constraint II | C++Python | O(n) | O(n) | Hard | Two Pointers, Sliding Window, Prefix Sum, Hash Table | |
3264 | Final Array State After K Multiplication Operations I | C++Python | O(nlogn) | O(n) | Easy | Sort, Two Pointers, Sliding Window, Fast Exponentiation, Heap, Binary Search, Simulation | |
3266 | Final Array State After K Multiplication Operations II | C++Python | O(nlogn) | O(n) | Hard | Sort, Two Pointers, Sliding Window, Fast Exponentiation, Heap, Binary Search | |
3297 | Count Substrings That Can Be Rearranged to Contain a String I | C++Python | O(n + 26) | O(26) | Medium | Two Pointers, Sliding Window, Freq Table | |
3298 | Count Substrings That Can Be Rearranged to Contain a String II | C++Python | O(n + 26) | O(26) | Hard | Two Pointers, Sliding Window, Freq Table | |
3305 | Count of Substrings Containing Every Vowel and K Consonants I | C++Python | O(n) | O(1) | Medium | Two Pointers, Sliding Window, Freq Table | |
3306 | Count of Substrings Containing Every Vowel and K Consonants II | C++Python | O(n) | O(1) | Medium | Two Pointers, Sliding Window, Freq Table | |
3318 | Find X-Sum of All K-Long Subarrays I | C++Python | O(nlogn) | O(n) | Easy | Two Pointers, Sliding Window, Freq Table, Ordered Set, Sorted List | |
3321 | Find X-Sum of All K-Long Subarrays II | C++Python | O(nlogn) | O(n) | Hard | Two Pointers, Sliding Window, Freq Table, Ordered Set, Sorted List | |
3323 | Minimize Connected Groups by Inserting Interval | C++Python | O(nlogn) | O(n) | Medium | 🔒 | Sort, Prefix Sum, Two Pointers, Sliding Window |
3325 | Count Substrings With K-Frequency Characters I | C++Python | O(n + 26) | O(26) | Medium | Freq Table, Two Pointers, Sliding Window | |
3329 | Count Substrings With K-Frequency Characters II | C++Python | O(n + 26) | O(26) | Hard | 🔒 | Freq Table, Two Pointers, Sliding Window |
3346 | Maximum Frequency of an Element After Performing Operations I | C++Python | O(nlogn) | O(n) | Medium | Sort, Freq Table, Two Pointers, Sliding Window, Difference Array, Line Sweep | |
3347 | Maximum Frequency of an Element After Performing Operations II | C++Python | O(nlogn) | O(n) | Hard | Sort, Freq Table, Two Pointers, Sliding Window, Difference Array, Line Sweep | |
3364 | Minimum Positive Sum Subarray | C++Python | O(nlogn) | O(n) | Easy | Prefix Sum, Two Pointers, Sliding Window, Sorted List, BST, Binary Search | |
3413 | Maximum Coins From K Consecutive Bags | C++Python | O(nlogn) | O(1) | Medium | Sort, Two Pointers, Sliding Window | |
3420 | Count Non-Decreasing Subarrays After K Operations | C++Python | O(n) | O(n) | Hard | Mono Deque, Two Pointers, Sliding Window | |
3422 | Minimum Operations to Make Subarray Elements Equal | C++Python | O(nlogk) | O(k) | Medium | 🔒 | Math, Two Pointers, Sliding Window, Sorted List, BST |
3425 | Longest Special Path | C++Python | O(n + e) | O(n + e) | Hard | DFS, Two Pointers, Sliding Window, Prefix Sum | |
3430 | Maximum and Minimum Sums of at Most Size K Subarrays | C++Python | O(n) | O(k) | Hard | Two Pointers, Sliding Window, Mono Deque | |
3439 | Reschedule Meetings for Maximum Free Time I | C++Python | O(n) | O(1) | Medium | Two Pointers, Sliding Window | |
3445 | Maximum Difference Between Even and Odd Frequency II | C++Python | O(d^2 * n) | O(n) | Hard | Prefix Sum, Two Pointers, Sliding Window | |
3460 | Longest Common Prefix After at Most One Removal | C++Python | O(n) | O(1) | Medium | 🔒 | Two Pointers |
3485 | Longest Common Prefix of K Strings After Removal | C++Python | O(l * nlogn) | O(n) | Hard | Sort, Sliding Window, Prefix Sum, Trie | |
3486 | Longest Special Path II | C++Python | O(n + e) | O(n + e) | Hard | DFS, Two Pointers, Sliding Window, Prefix Sum | |
3555 | Smallest Subarray to Sort in Every Sliding Window | C++Python | O(n) | O(n) | Medium | 🔒 | Mono Stack, Two Pointers |
3567 | Minimum Absolute Difference in Sliding Submatrix | C++Python | O(m * n * k^2) | O(k^2) | Medium | Brute Force, Sort, Two Pointers, Sliding Window, BST, Sorted List | |
3584 | Maximum Product of First and Last Elements of a Subsequence | C++Python | O(n) | O(1) | Medium | Two Pointers, Sliding Window | |
3589 | Count Prime-Gap Balanced Subarrays | C++Python | precompute:O(r) runtime:O(n) | O(r) | Medium | Number Theory,Linear Sieve of Eratosthenes , Mono Deque, Two Pointers, Sliding Window | |
3634 | Minimum Removals to Balance Array | C++Python | O(nlogn) | O(1) | Medium | Sort, Two Pointers, Sliding Window | |
3640 | Trionic Array II | C++Python | O(n) | O(1) | Easy | Two Pointers, Sliding Window, Greedy | |
3641 | Longest Semi-Repeating Subarray | C++Python | O(n) | O(1) | Medium | 🔒 | Freq Table, Two Pointers, Sliding Window |
3649 | Number of Perfect Pairs | C++Python | O(nlogn) | O(1) | Medium | Sort, Two Pointers, Sliding Window, Math | |
3652 | Best Time to Buy and Sell Stock using Strategy | C++Python | O(n) | O(1) | Medium | Two Pointers, Sliding Window | |
3672 | Sum of Weighted Modes in Subarrays | C++Python | O(nlogk) | O(k) | Medium | 🔒 | Sorted List, BST, Two Pointers, Sliding Window |
3679 | Minimum Discards to Balance Inventory | C++Python | O(n) | O(w) | Medium | Freq Table, Two Pointers, Sliding Window | |
3698 | Split Array With Minimum Difference | C++Python | O(n) | O(1) | Medium | Two Pointers |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
2613 | Beautiful Pairs | C++Python | O(n) on average | O(n) | Hard | 🔒, variant ofSPOJ - Closest Point Pair | Random Algorithms, Divide and Conquer, Merge Sort, Segment Tree |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
2064 | Minimized Maximum of Products Distributed to Any Store | C++Python | O(nlogm) | O(1) | Medium | variant ofMinimum Limit of Balls in a Bag | |
2111 | Minimum Operations to Make the Array K-Increasing | C++Python | O(nlog(n/k)) | O(n/k) | Hard | variant ofLongest Increasing Subsequence | |
2137 | Pour Water Between Buckets to Make Water Levels Equal | C++Python | O(nlogr) | O(1) | Medium | 🔒 | |
2187 | Minimum Time to Complete Trips | C++Python | O(nlogr) | O(1) | Medium | ||
2226 | Maximum Candies Allocated to K Children | C++Python | O(nlogr) | O(1) | Medium | Binary Search | |
2250 | Count Number of Rectangles Containing Each Point | C++Python | O(nlogn + m * max_y * logn) | O(n) | Medium | Bucket Sort, Binary Search | |
2300 | Successful Pairs of Spells and Potions | C++Python | O(mlogm + nlogm) | O(1) | Medium | Binary Search | |
2333 | Minimum Sum of Squared Difference | C++Python | O(nlogn + nlogr) | O(1) | Medium | Binary Search | |
2387 | Median of a Row Wise Sorted Matrix | C++Python | O(logr * mlogn) | O(1) | Medium | 🔒 | Binary Search |
2389 | Longest Subsequence With Limited Sum | C++Python | O(nlogn + qlogn) | O(1) | Easy | Greedy, Sort, Binary Search | |
2448 | Minimum Cost to Make Array Equal | C++Python | O(nlogn) | O(n) | Hard | Math, Binary Search, Prefix Sum | |
2476 | Closest Nodes Queries in a Binary Search Tree | C++Python | O(n + qlogn) | O(n) | Hard | DFS, Binary Search | |
2513 | Minimize the Maximum of Two Arrays | C++Python | O(log(min(d1, d2))) | O(1) | Medium | Number Theory, Binary Search | |
2517 | Maximum Tastiness of Candy Basket | C++Python | O(nlogr) | O(1) | Medium | Binary Search, Greedy | |
2528 | Maximize the Minimum Powered City | C++Python | O(nlogk) | O(n) | Hard | Binary Search, Sliding Window, Greedy | |
2529 | Maximum Count of Positive Integer and Negative Integer | C++Python | O(logn) | O(1) | Easy | Binary Search | |
2554 | Maximum Number of Integers to Choose From a Range I | C++Python | O(b) | O(b) | Medium | Math, Binary Search, Prefix Sum, Greedy | |
2557 | Maximum Number of Integers to Choose From a Range II | C++Python | O(b) | O(b) | Medium | 🔒 | Math, Binary Search, Prefix Sum |
2560 | House Robber IV | C++Python | O(nlogn) | O(n) | Medium | Binary Search, Greedy | |
2594 | Minimum Time to Repair Cars | C++Python | O(mx * (logc + log(mn))) | O(mx) | Medium | Freq Table, Binary Search, Heap, Simulation | |
2602 | Minimum Operations to Make All Array Elements Equal | C++Python | O(nlogn + qlogn) | O(n) | Medium | Sort, Binary Search, Prefix Sum | |
2616 | Minimize the Maximum Difference of Pairs | C++Python | O(nlogn + nlogr) | O(1) | Medium | Sort, Binary Search, Greedy | |
2702 | Minimum Operations to Make Numbers Non-positive | C++Python | O(nlogr) | O(1) | Hard | 🔒 | Binary Search, Greedy |
2936 | Number of Equal Numbers Blocks | C++Python | O(klogn) | O(1) | Medium | 🔒 | Binary Search |
2940 | Find Building Where Alice and Bob Can Meet | C++Python | O(n + qlogn) | O(n) | Hard | Heap, Mono Stack, Binary Search, Online Solution, Segment Tree | |
3048 | Earliest Second to Mark Indices I | C++Python | O(mlogm) | O(n) | Medium | Binary Search, Greedy | |
3049 | Earliest Second to Mark Indices II | C++Python | O((m + nlogn) *logm) | O(n) | Hard | Binary Search, Greedy, Heap | |
3104 | Find Longest Self-Contained Substring | C++Python | O(n + 26^3 * logn) | O(n) | Hard | 🔒 | Brute Force, Freq Table, Two Pointers, Hash Table, Binary Search |
3116 | Kth Smallest Amount With Single Denomination Combination | C++Python | O(n * 2^n * logk) | O(2^n) | Hard | Binary Search, Principle of Inclusion and Exclusion, Number Theory | |
3134 | Find the Median of the Uniqueness Array | C++Python | O(nlogn) | O(n) | Hard | Binary Search, Two Pointers, Sliding Window | |
3135 | Equalize Strings by Adding or Removing Characters at Ends | C++Python | O((n + m) * log(min(n, m))) | O(min(n, m)) | Medium | 🔒 | Binary Search,Rabin-Karp Algorithm , Rolling Hash, DP |
3145 | Find Products of Elements of Big Array | C++Python | O(q * (logr)^2) | O(1) | Hard | Binary Search, Combinatorics, Bitmasks, Fast Exponentiation | |
3231 | Minimum Number of Increasing Subsequence to Be Removed | C++Python | O(nlogn) | O(n) | Hard | 🔒, variant ofLongest Increasing Subsequence | Binary Search |
3233 | Find the Count of Numbers Which Are Not Special | C++Python | precompute:O(sqrt(r)) runtime:O(logr) | O(sqrt(r)) | Medium | Number Theory,Linear Sieve of Eratosthenes , Binary Search | |
3281 | Maximize Score of Numbers in Ranges | C++Python | O(nlogr) | O(1) | Medium | Binary Search, Greedy | |
3288 | Length of the Longest Increasing Path | C++Python | O(nlogn) | O(n) | Hard | Sort, Binary Search, Longest Increasing Subsequence | |
3296 | Minimum Number of Seconds to Make Mountain Height Zero | C++Python | O(nlogr) | O(1) | Medium | Binary Search, Quadratic Equation, Heap | |
3356 | Zero Array Transformation II | C++Python | O((n + q) * logn) | O(n) | Medium | Binary Search, Line Sweep | |
3357 | Minimize the Maximum Adjacent Element Difference | C++Python | O(nlogr) | O(1) | Hard | Binary Search | |
3398 | Smallest Substring With Identical Characters I | C++Python | O(nlogn) | O(1) | Hard | Binary Search, Greedy | |
3399 | Smallest Substring With Identical Characters II | C++Python | O(nlogn) | O(1) | Hard | Binary Search, Greedy | |
3449 | Maximize the Minimum Game Score | C++Python | O(n * log(m * r)) | O(1) | Hard | Binary Search, Greedy | |
3464 | Maximize the Distance Between Points on a Square | C++Python | O(nlogn + nlogs) | O(n) | Hard | Sort, Binary Search, Greedy, Two Pointers, Sliding Window | |
3477 | Fruits Into Baskets II | C++Python | O(nlogn) | O(n) | Easy | Segment Tree, Binary Search, Brute Force | |
3479 | Fruits Into Baskets III | C++Python | O(nlogn) | O(n) | Medium | Segment Tree, Binary Search | |
3520 | Minimum Threshold for Inversion Pairs Count | C++Python | O(nlogn * logr) | O(n) | Medium | 🔒 | Binary Search, Sorted List, Ordered Set |
3605 | Minimum Stability Factor of Array | C++Python | O(nlogn * logr) | O(nlogn) | Hard | Number Theory, Binary Search, RMQ, Sparse Table, Greedy |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
2426 | Number of Pairs Satisfying Inequality | C++Python | O(nlogn) | O(n) | Hard | Merge Sort, Two Pointers, BIT, Fenwick Tree, Coordinate Compression, Sorted List, Ordered Set, Binary Search | |
2689 | Extract Kth Character From The Rope Tree | C++Python | O(h) | O(1) | Medium | 🔒 | BST |
2817 | Minimum Absolute Difference Between Elements With Constraint | C++Python | O(nlogn) | O(n) | Medium | Sorted List, BST, Binary Search | |
2907 | Maximum Profitable Triplets With Increasing Prices I | C++Python | O(nlogn) | O(n) | Medium | 🔒 | Prefix Sum, Sorted List, BST, Binary Search, Mono Stack, BIT, Fenwick Tree, Segment Tree |
2921 | Maximum Profitable Triplets With Increasing Prices II | C++Python | O(nlogn) | O(n) | Hard | 🔒 | Prefix Sum, Sorted List, BST, Binary Search, Mono Stack, BIT, Fenwick Tree, Segment Tree |
2926 | Maximum Balanced Subsequence Sum | C++Python | O(nlogn) | O(n) | Hard | Sorted List, BST, Binary Search, Mono Stack, BIT, Fenwick Tree, Segment Tree | |
3072 | Distribute Elements Into Two Arrays II | C++Python | O(nlogn) | O(n) | Hard | Sorted List, Ordered Set | |
3073 | Maximum Increasing Triplet Value | C++Python | O(nlogn) | O(n) | Medium | 🔒 | Sorted List, BST, Prefix Sum |
3161 | Block Placement Queries | C++Python | O(qlogq) | O(q) | Hard | Sorted List, BST, BIT, Fenwick Tree, Segment Tree | |
3165 | Maximum Sum of Subsequence With Non-adjacent Elements | C++Python | O(n + qlogn) | O(n) | Hard | Segment Tree | |
3526 | Range XOR Queries with Subarray Reversals | C++Python | O(n + qlogn) | O(n) | Hard | 🔒 | Treap |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
2014 | Longest Subsequence Repeated k Times | C++Python | O(n * (n/k)!) | O(n/k) | Hard | ||
2056 | Number of Valid Move Combinations On Chessboard | C++Python | O(1) | O(1) | Hard | ||
2094 | Finding 3-Digit Even Numbers | C++Python | O(n) | O(1) | Easy | ||
2443 | Sum of Number and Its Reverse | C++Python | O(n^(1/(2*log2(10)))) | O(log10(n)/2) | Medium | Brute Force, Backtracking | |
2664 | The Knight’s Tour | C++Python | O(m * n) | O(1) | Medium | 🔒 | Backtracking, Greedy,Warnsdorff's Rule |
2698 | Find the Punishment Number of an Integer | C++Python | O(n * (logn)^(2*logn)) | O(logn) | Medium | Backtracking | |
2741 | Special Permutations | C++Python | O(n^2 * 2^n) | O(n * 2^n) | Medium | Backtracking, Memoization | |
3211 | Generate Binary Strings Without Adjacent Zeros | C++Python | O(n * 2^n) | O(n) | Medium | Backtracking, BFS | |
3437 | Permutations III | C++Python | O(n * n!) | O(n) | Medium | 🔒 | Backtracking, Bitmasks |
3565 | Sequential Grid Path Cover | C++Python | O(m * n * 3^(m * n)) | O(m * n) | Medium | 🔒 | Backtracking |
3669 | Balanced K-Factor Decomposition | C++Python | precompute:O(rlogr) runtime:O(k * (logn)^(k - 1)) | O(rlogr) | Medium | Backtracking, Number Theory |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
2076 | Process Restricted Friend Requests | C++Python | O(n * r) | O(n) | Hard | Union Find | |
2077 | Paths in Maze That Lead to Same Room | C++Python | O(|V|^3) | O(|E|) | Medium | 🔒 | |
2092 | Find All People With Secret | C++Python | O(nlogn) | O(nlogn) | Hard | BFS, DFS, Union Find | |
2093 | Minimum Path Cost in a Hidden Grid | C++Python | O(|E| * log|V|) | O(|V| + |E|) | Medium | variant ofCheapest Flights Within K Stops, 🔒 | Dijkstra's Algorithm , DP |
2097 | Valid Arrangement of Pairs | C++Python | O(|V| + |E|) | O(|V| + |E|) | Hard | variant ofReconstruct Itinerary | Hierholzer's Algorithm , Eulerian Path |
2123 | Minimum Operations to Remove Adjacent Ones in Matrix | C++Python | O(m * n * sqrt(m * n)) | O(m + n) | Hard | variant ofMaximum Students Taking Exam, 🔒 | Hopcroft-Karp Bipartite Matching , Maximum Independent Set |
2127 | Maximum Employees to Be Invited to a Meeting | C++Python | O(n) | O(n) | Hard | ||
2172 | Maximum AND Sum of Array | C++Python | O(n^3) | O(n^2) | Hard | variant ofMaximum Compatibility Score Sum | DP,Hungarian Weighted Bipartite Matching |
2203 | Minimum Weighted Subgraph With the Required Paths | C++Python | O(|E| * log|V|) | O(|E|) | Hard | Dijkstra's Algorithm | |
2204 | Distance to a Cycle in Undirected Graph | C++Python | O(|V| + |E|) | O(|V| + |E|) | Hard | 🔒 | Graph, DFS, BFS |
2242 | Maximum Score of a Node Sequence | C++Python | O(|V| + |E|) | O(|V|) | Hard | Graph | |
2307 | Check for Contradictions in Equations | C++Python | O(e + q) | O(n) | Hard | 🔒, variant ofEvaluate Division | DFS, Union Find |
2359 | Find Closest Node to Given Two Nodes | C++Python | O(n) | O(n) | Medium | Graph, Hash Table, DFS | |
2360 | Longest Cycle in a Graph | C++Python | O(n) | O(n) | Hard | Graph, Hash Table, DFS | |
2392 | Build a Matrix With Conditions | C++Python | O(k^2 + r + c) | O(k + r + c) | Hard | Graph, Topological Sort | |
2473 | Minimum Cost to Buy Apples | C++Python | O(n * rlogn) | O(n) | Medium | 🔒 | Dijkstra's Algorithm |
2508 | Add Edges to Make Degrees of All Nodes Even | C++Python | O(n) | O(n) | Hard | Graph | |
2608 | Shortest Cycle in a Graph | C++Python | O(n^2) | O(n + e) | Hard | Graph, BFS | |
2662 | Minimum Cost of a Path With Special Roads | C++Python | O(n^2) | O(n^2) | Medium | Graph,Dijkstra's Algorithm | |
2699 | Modify Graph Edge Weights | C++Python | O(|E| * log|V|) | O(|E|) | Hard | Graph,Dijkstra's Algorithm | |
2714 | Find Shortest Path with K Hops | C++Python | O(n * k + (k * e) * log(n * k)) | O(n * k + e) | Hard | 🔒 | Graph,Dijkstra's Algorithm |
2737 | Find the Closest Marked Node | C++Python | O(|E| * log|V|) | O(|E|) | Medium | 🔒 | Graph,Dijkstra's Algorithm |
2836 | Maximize Value of Function in a Ball Passing Game | C++Python | O(n) | O(n) | Hard | Graph, Prefix Sum, Two Pointers, Sliding Window, Binary Lifting | |
2850 | Minimum Moves to Spread Stones Over Grid | C++Python | O(n^3) | O(n^2) | Medium | Backtracking,Hungarian Weighted Bipartite Matching | |
2876 | Count Visited Nodes in a Directed Graph | C++Python | O(n) | O(n) | Hard | Graph, Hash Table, Stack | |
2924 | Find Champion II | C++Python | O(n) | O(n) | Medium | Graph, Hash Table | |
2959 | Number of Possible Sets of Closing Branches | C++Python | O(r + 2^n * n^2) | O(n^3) | Medium | Graph, Bitmasks,Floyd-Warshall Algorithm , Backtracking | |
3108 | Minimum Cost Walk in Weighted Graph | C++Python | O(n + e + q) | O(n) | Hard | Union Find | |
3112 | Minimum Time to Visit Disappearing Nodes | C++Python | O(|E| * log|V|) | O(|E|) | Medium | Graph,Dijkstra's Algorithm | |
3123 | Find Edges in Shortest Paths | C++Python | O(|E| * log|V|) | O(|E|) | Hard | Graph,Dijkstra's Algorithm | |
3235 | Check if the Rectangle Corner Is Reachable | C++Python | O(n^2) | O(n) | Hard | Graph, BFS, DFS, Union Find | |
3243 | Shortest Distance After Road Addition Queries I | C++Python | O(n^2) | O(n^2) | Medium | Graph,Dijkstra's Algorithm , BFS | |
3244 | Shortest Distance After Road Addition Queries II | C++Python | O(nlogn) | O(n) | Hard | Graph, BST, Sorted List | |
3265 | Count Almost Equal Pairs I | C++Python | O(n * l^2) | O(n) | Medium | Freq Table, Combinatorics, Graph, BFS | |
3267 | Count Almost Equal Pairs II | C++Python | O(n * l^4) | O(n) | Hard | Freq Table, Combinatorics, Graph, BFS | |
3276 | Select Cells in Grid With Maximum Score | C++Python | O(n^2 * max(n, r)) | O(n * max(n, r)) | Hard | variant ofMaximum Compatibility Score Sum | Hungarian Weighted Bipartite Matching , DP, Bitmasks |
3310 | Remove Methods From Project | C++Python | O(n + e) | O(n + e) | Medium | Graph, BFS | |
3341 | Find Minimum Time to Reach Last Room I | C++Python | O(n * m * log(n * m)) | O(n * m) | Medium | Graph,Dijkstra's Algorithm | |
3342 | Find Minimum Time to Reach Last Room II | C++Python | O(n * m * log(n * m)) | O(n * m) | Medium | Graph,Dijkstra's Algorithm | |
3377 | Digit Operations to Make Two Integers Equal | C++Python | O(nlogn) | O(n) | Medium | Graph, Number Theory,Linear Sieve of Eratosthenes ,Dijkstra's Algorithm | |
3378 | Count Connected Components in LCM Graph | C++Python | O(n + tlogt) | O(t) | Hard | Number Theory, Graph, Union Find | |
3383 | Minimum Runes to Add to Cast Spell | C++Python | O(n) | O(n) | Hard | 🔒 | Graph,Tarjan's Strongly Connected Components Algorithm , SCC |
3376 | Minimum Time to Break Locks I | C++Python | O(n^3) | O(n^2) | Medium | Bitmasks, DP, Graph,Hungarian Weighted Bipartite Matching | |
3385 | Minimum Time to Break Locks II | C++Python | O(n^3) | O(n^2) | Hard | 🔒 | Graph,Hungarian Weighted Bipartite Matching |
3387 | Maximize Amount After Two Days of Conversions | C++Python | O(n^2) | O(n) | Medium | Bellman-Ford Algorithm , BFS | |
3419 | Minimize the Maximum Edge Weight of Graph | C++Python | O(nlogn + e) | O(n + e) | Medium | Graph,Dijkstra's Algorithm ,Prim's Algorithm , Binary Search, BFS | |
3435 | Frequencies of Shortest Supersequences | C++Python | O(n + k^2 * 2^k) | O(k^2) | Hard | Bitmasks, Graph, Topological Sort | |
3481 | Apply Substitutions | C++Python | O(r * 2^r) | O(r * 2^r) | Medium | 🔒 | Graph, Topological Sort, Memoization |
3493 | Properties Graph | C++Python | O(n^2 * m) | O(n) | Medium | Graph, Flood Fill, BFS, Union Find | |
3532 | Path Existence Queries in a Graph I | C++Python | O(n + q) | O(n) | Medium | Prefix Sum | |
3534 | Path Existence Queries in a Graph II | C++Python | O((n + q) * logn) | O(nlogn) | Hard | Prefix Sum, Greedy, Binary Lifting | |
3536 | Maximum Product of Two Digits | C++Python | O(d + 10) | O(10) | Easy | Freq Table, Greedy | |
3547 | Maximum Sum of Edge Values in a Graph | C++Python | O(n) | O(n) | Hard | Flood Fill, BFS, Counting Sort, Greedy | |
3594 | Minimum Time to Transport All Individuals | C++Python | O(m * 3^n * log(m * 3^n)) | O(m * 3^n) | Hard | Graph,Dijkstra's Algorithm , Submask Enumeration | |
3600 | Maximize Spanning Tree Stability with Upgrades | C++Python | O(n + eloge) | O(n) | Hard | MST, Maximum Spanning Tree, Union Find,Kruskal's Algorithm , Greedy | |
3604 | Minimum Time to Reach Destination in Directed Graph | C++Python | O(n + elogn) | O(n + e) | Medium | Graph,Dijkstra's Algorithm | |
3620 | Network Recovery Pathways | C++Python | O((n + e) * logr) | O(n + e) | Hard | Binary Search, Topological Sort, DP | |
3650 | Minimum Cost Path with Edge Reversals | C++Python | O(n + elogn) | O(n + e) | Medium | Graph,Dijkstra's Algorithm | |
3656 | Determine if a Simple Graph Exists | C++Python | O(nlogn) | O(1) | Medium | 🔒 | Graph,Erdős–Gallai Theorem , Sort, Prefix sum, Two Pointers |
3660 | Jump Game IX | C++Python | O(n) | O(1) | Medium | Graph, Prefix Sum |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
2101 | Detonate the Maximum Bombs | C++Python | O(|V|^2 + \V| * |E|) | O(\V| + |E|) | Medium | Graph, DFS, BFS | |
3453 | Separate Squares I | C++Python | O(nlogn) | O(n) | Medium | Binary Search, Sort, Line Sweep | |
3454 | Separate Squares II | C++Python | O(nlogn) | O(n) | Hard | Sort, Line Sweep, Segment Tree |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
2013 | Detect Squares | C++Python | ctor:O(1) add:O(1) count:O(n) | O(n) | Medium | ||
2034 | Stock Price Fluctuation | C++Python | ctor:O(1) update:O(logn) current:O(1) max:O(1) min:O(1) | O(n) | Medium | Sorted List, Heap | |
2043 | Simple Bank System | C++Python | ctor:O(1) transer:O(1) deposit:O(1) withdraw:O(1) | O(1) | Medium | ||
2069 | Walking Robot Simulation II | C++Python | O(1) | O(1) | Medium | Simulation, Math | |
2080 | Range Frequency Queries | C++Python | ctor:O(n) query:O(logn) | O(n) | Medium | Binary Search | |
2102 | Sequentially Ordinal Rank Tracker | C++Python | add:O(logn) get:O(logn) | O(n) | Hard | Sorted List | |
2166 | Design Bitset | C++Python | ctor:O(n) fix:O(1) fix:O(1) unfix:O(1) flip:O(1) all:O(1) one:O(1) count:O(1) toString:O(n) | O(n) | Medium | ||
2227 | Encrypt and Decrypt Strings | C++Python | ctor:O(m + d) encrypt:O(n) decrypt:O(n) | O(n) | Hard | Freq Table | |
2241 | Design an ATM Machine | C++Python | ctor:O(1) deposit:O(1) withdraw:O(1) | O(1) | Medium | Greedy | |
2254 | Design Video Sharing Platform | C++Python | ctor:O(1) upload:O(logn + l) remove:O(logn) like:O(1) dislike:O(1) view:O(1) getLikesAndDislikes:O(1) getViews:O(1) | O(n * l) | Hard | 🔒 | Heap |
2276 | Count Integers in Intervals | C++Python | ctor:O(1) add:O(logn), amortized Count:O(1) | O(n) | Hard | Sorted List | |
2286 | Booking Concert Tickets in Groups | C++Python | ctor:O(n) gather:O(logn) scatter:O(logn), amortized | O(n) | Hard | Segment Tree, Binary Search | |
2296 | Design a Text Editor | C++Python | ctor:O(1) addText:O(l) deleteText:O(k) cursorLeft:O(k) cursorRight:O(k) | O(n) | Hard | Stack | |
2336 | Smallest Number in Infinite Set | C++Python | ctor:O(1) popSmallest:O(logn) addBack:O(logn) | O(n) | Medium | Heap, BST | |
2349 | Design a Number Container System | C++Python | ctor:O(1) change:O(logn) find:O(1) | O(n) | Medium | Sorted List, BST | |
2353 | Design a Food Rating System | C++Python | ctor:O(nlogn) changeRating:O(logn) highestRated:O(1) | O(n) | Medium | Sorted List, BST | |
2408 | Design SQL | C++Python | ctor:O(t * max_m) insertRow:O(m) deleteRow:O(1) selectCell:O(m) | O(d) | Medium | 🔒 | Hash Table |
2424 | Longest Uploaded Prefix | C++Python | ctor:O(1) upload:O(1), amortized longest:O(1) | O(n) | Medium | Hash Table | |
2502 | Design Memory Allocator | C++Python | ctor:O(1) allocate:O(logn) free:O(logn) | O(n) | Medium | Sorted List | |
2526 | Find Consecutive Integers from a Data Stream | C++Python | O(1) | O(1) | Medium | Array | |
2590 | Design a Todo List | C++Python | ctor:O(1) addTask:O(l + logn) getAllTasks:O(r) getTasksForTag:O(r * c) completeTask:O(l + logn) | O(n * l) | Medium | 🔒 | BST, Sorted List |
2642 | Design Graph With Shortest Path Calculator | C++Python | ctor:O(|V| + |E|) addEdge:O(1) shortestPath:O(|E| * log|V|) | O(|E|) | Hard | Dijkstra's Algorithm | |
2671 | Frequency Tracker | C++Python | ctor:O(1) add:O(1) deleteOne:O(1) hasFrequency:O(1) | O(min(n, r)) | Medium | Freq Table | |
3242 | Design Neighbor Sum Service | C++Python | ctor:O(n^2) adjacentSum:O(1) diagonalSum:O(1) | O(n^2) | Easy | Hash Table | |
3369 | Design an Array Statistics Tracker | C++Python | ctor:O(1) addNumber:O(logn) removeFirstAddedNumber:O(logn) getMean:O(1) getMedian:O(1) getMode:O(1) | O(n) | Hard | 🔒 | Deque, Freq Table, Sorted List, BST |
3391 | Design a 3D Binary Matrix with Efficient Layer Tracking | C++Python | ctor:O(1) setCell:O(logn) unsetCell:O(logn) largestMatrix:O(logn) | O(n^3) | Medium | 🔒 | Heap, Sorted List |
3408 | Design Task Manager | C++Python | ctor:O(tlogt) add:O(logt) edit:O(logt) rmv:O(logt) execTop:O(logt) | O(t) | Medium | Sorted List | |
3484 | Design Spreadsheet | C++Python | ctor:O(1) setCell:O(1) resetCell:O(1) getValue:O(1) | O(n) | Medium | Hash Table | |
3508 | Implement Router | C++Python | ctor:O(1) addPacket:O(logn) forwardPacket:O(logn) getCount:O(logn) | O(n) | Medium | Queue, Sorted List, Ordered Set |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
2877 | Create a DataFrame from List | Python3 | O(n) | O(1) | Easy | ||
2878 | Get the Size of a DataFrame | Python3 | O(1) | O(1) | Easy | ||
2879 | Display the First Three Rows | Python3 | O(1) | O(1) | Easy | ||
2880 | Select Data | Python3 | O(n) | O(n) | Easy | ||
2881 | Create a New Column | Python3 | O(n) | O(1) | Easy | ||
2882 | Drop Duplicate Rows | Python3 | O(n) | O(n) | Easy | ||
2883 | Drop Missing Data | Python3 | O(n) | O(1) | Easy | ||
2884 | Modify Columns | Python3 | O(n) | O(1) | Easy | ||
2885 | Rename Columns | Python3 | O(n) | O(1) | Easy | ||
2886 | Change Data Type | Python3 | O(n) | O(1) | Easy | ||
2887 | Fill Missing Data | Python3 | O(n) | O(1) | Easy | ||
2888 | Reshape Data: Concatenate | Python3 | O(n + m) | O(1) | Easy | ||
2889 | Reshape Data: Pivot | Python3 | O(n) | O(1) | Easy | ||
2890 | Reshape Data: Melt | Python3 | O(n) | O(1) | Easy | ||
2891 | Method Chaining | Python3 | O(nlogn) | O(n) | Easy |
About
🏋️ Python / Modern C++ Solutions of All 3706 LeetCode Problems (Weekly Update)
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
No releases published
Packages0
No packages published
Uh oh!
There was an error while loading.Please reload this page.