LeetCode
June 16, 2026 · View on GitHub
- R.I.P. to my old Leetcode repository, where there were
5.7k+stars and2.2k+forks (ever the top 3 in the field). - Since free questions may be even mistakenly taken down by some companies, only solutions will be post on now.
- There are new LeetCode questions every week. I'll keep updating for full summary and better solutions.
- For more problem solutions, you can see my LintCode, GoogleKickStart, GoogleCodeJamIO repositories.
- For more challenging problem solutions, you can also see my GoogleCodeJam, MetaHackerCup repositories.
- Hope you enjoy the journey of learning data structures and algorithms.
- Notes: "🔒" means your subscription of LeetCode premium membership is required for reading the question.
Solutions
Algorithms
- 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
JavaScript
Database
Pandas
Reference
Bit Manipulation
Array
String
Linked List
| # | Title | Solution | Time | Space | Difficulty | Tag | Note |
|---|---|---|---|---|---|---|---|
| 3062 | Winner of the Linked List Game | C++ Python | O(n) | O(1) | Easy | 🔒 | Linked List |
| 3063 | Linked List Frequency | C++ Python | O(n) | O(1) | Medium | 🔒 | Linked List |
| 3217 | Delete Nodes From Linked List Present in Array | C++ Python | O(n) | O(m) | Medium | Hash Table, Linked List | |
| 3263 | Convert Doubly Linked List to Array I | C++ Python | O(n) | O(1) | Easy | 🔒 | Linked List |
| 3294 | Convert Doubly Linked List to Array II | C++ Python | O(n) | O(1) | Medium | 🔒 | Linked List |
Stack
| # | Title | Solution | Time | Space | Difficulty | Tag | Note |
|---|---|---|---|---|---|---|---|
| 3113 | Find the Number of Subarrays Where Boundary Elements Are Maximum | C++ Python | O(n) | O(n) | Hard | Mono Stack, Combinatorics | |
| 3174 | Clear Digits | C++ Python | O(n) | O(1) | Easy | Stack, Two Pointers | |
| 3676 | Count Bowl Subarrays | C++ Python | O(n) | O(n) | Medium | Mono Stack | |
| 3703 | Remove K-Balanced Substrings | C++ Python | O(n) | O(n) | Medium | Stack | |
| 3749 | Evaluate Valid Expressions | C++ Python | O(n) | O(n) | Hard | 🔒 | Stack |
| 3834 | Merge Adjacent Equal Elements | C++ Python | O(n) | O(1) | Medium | Stack, Simulation | |
| 3878 | Count Good Subarrays | C++ Python | O(n) | O(n) | Hard | Combinatorics, Mono Stack |
Queue
| # | Title | Solution | Time | Space | Difficulty | Tag | Note |
|---|
Binary Heap
| # | Title | Solution | Time | Space | Difficulty | Tag | Note |
|---|---|---|---|---|---|---|---|
| 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 | |
| 3781 | Maximum Score After Binary Swaps | C++ Python | O(nlogn) | O(n) | Medium | Heap | |
| 3962 | Maximum Subarray Sum After at Most K Swaps | C++ Python | O(n^2 * logk) | O(n) | Hard | Prefix Sum, Heap, DP |
Tree
| # | Title | Solution | Time | Space | Difficulty | Tag | Note |
|---|---|---|---|---|---|---|---|
| 3109 | Find the Index of Permutation | C++ Python | O(nlogn) | O(n) | 🔒, Medium | variant of Count 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 | |
| 3715 | Sum of Perfect Square Ancestors | C++ Python | precompute: O(r) runtime: O(nlogx) | O(r + n) | Hard | Tree, Number Theory, Linear Sieve of Eratosthenes, Freq Table, DFS | |
| 3841 | Palindromic Path Queries in a Tree | C++ Python | O((n + q) * logn) | O(n) | Hard | DFS, HLD, Heavy-Light Decomposition, LCA, Binary Lifting, BIT, Fenwick Tree | |
| 3879 | Maximum Distinct Path Sum in a Binary Tree | C++ Python | O(n^2) | O(n) | Medium | DFS, BFS |
Hash Table
Math
| # | Title | Solution | Time | Space | Difficulty | Tag | Note |
|---|---|---|---|---|---|---|---|
| 3001 | Minimum Moves to Capture The Queen | C++ Python | O(1) | O(1) | Medium | Math | |
| 3007 | Maximum Number That Sum of the Prices Is Less Than or Equal to K | C++ Python | O(max(logk, x) * log((logk) / x)) | O((logk) / x) | Medium | Bit Manipulation, Binary Search, Combinatorics | |
| 3021 | Alice and Bob Playing Flower Game | C++ Python | O(1) | O(1) | Medium | Combinatorics | |
| 3024 | Type of Triangle II | C++ Python | O(1) | O(1) | Easy | Math | |
| 3032 | Count Numbers With Unique Digits II | C++ Python | O(logb) | O(1) | Easy | 🔒, variant of Count Numbers With Unique Digits | Brute Force, Hash Table, Bitmasks, Combinatorics |
| 3047 | Find the Largest Area of Square Inside Two Rectangles | C++ Python | O(n^2) | O(1) | Meidum | Brute Force, Math | |
| 3084 | Count Substrings Starting and Ending with Given Character | C++ Python | O(n) | O(1) | Meidum | Combinatorics | |
| 3091 | Apply Operations to Make Sum of Array Greater Than or Equal to k | C++ Python | O(logn) | O(1) | Meidum | Codeforces Round #674 C | Math |
| 3099 | Harshad Number | C++ Python | O(logx) | O(1) | Easy | Math | |
| 3102 | Minimize Manhattan Distances | C++ Python | O(n) | O(1) | Hard | Math | |
| 3115 | Maximum Prime Difference | C++ Python | O(r + n) | O(r) | Medium | Array, Number Theory, Linear Sieve of Eratosthenes | |
| 3128 | Right Triangles | C++ Python | O(n * m) | O(min(n, m)) | Medium | Array, Combinatorics, Freq Table | |
| 3154 | Find Number of Ways to Reach the K-th Stair | C++ Python | O(logk) | O(logk) | Hard | Combinatorics | |
| 3155 | Maximum Number of Upgradable Servers | C++ Python | O(n) | O(1) | Medium | 🔒 | Math |
| 3162 | Find the Number of Good Pairs I | C++ Python | O(rlogr + n + m) | O(r) | Easy | Brute Force, Number Theory, Freq Table | |
| 3164 | Find the Number of Good Pairs II | C++ Python | O(rlogr + n + m) | O(r) | Medium | Number Theory, Freq Table | |
| 3178 | Find the Child Who Has the Ball After K Seconds | C++ Python | O(1) | O(1) | Easy | Math | |
| 3179 | Find the N-th Value After K Seconds | C++ Python | O(n + k) | O(n + k) | Medium | Prefix Sum, Combinatorics | |
| 3183 | The Number of Ways to Make the Sum | C++ Python | O(1) | O(1) | Medium | 🔒 | Math, DP |
| 3190 | Find Minimum Operations to Make All Elements Divisible by Three | C++ Python | O(n) | O(1) | Easy | Math | |
| 3200 | Maximum Height of a Triangle | C++ Python | O(logn) | O(1) | Easy | Simulation, Math | |
| 3222 | Find the Winning Player in Coin Game | C++ Python | O(1) | O(1) | Easy | Math | |
| 3227 | Vowels Game in a String | C++ Python | O(n) | O(1) | Medium | Math | |
| 3232 | Find if Digit Game Can Be Won | C++ Python | O(n) | O(1) | Easy | Brute Force, Game Theory | |
| 3247 | Number of Subsequences with Odd Sum | C++ Python | O(n) | O(1) | Medium | 🔒 | Combinatorics, Fast Exponentiation, DP |
| 3250 | Find the Count of Monotonic Pairs I | C++ Python | O(n + r) | O(n + r) | Hard | Combinatorics, Stars and Bars, DP, Prefix Sum | |
| 3251 | Find the Count of Monotonic Pairs II | C++ Python | O(n + r) | O(n + r) | Hard | Combinatorics, Stars and Bars, DP, Prefix Sum | |
| 3270 | Find the Key of the Numbers | C++ Python | O(d) | O(1) | Easy | Math | |
| 3272 | Find the Count of Good Integers | C++ Python | O(n + 10 * 10^((n + 1)/2)) | O(n + 10 * (10 * nHr(10, n/2))) | Hard | Combinatorics, Freq Table | |
| 3274 | Check if Two Chessboard Squares Have the Same Color | C++ Python | O(1) | O(1) | Easy | Math, Parity | |
| 3284 | Sum of Consecutive Subarrays | C++ Python | O(n) | O(1) | Medium | 🔒 | Combinatorics |
| 3299 | Sum of Consecutive Subsequences | C++ Python | O(n) | O(n) | Hard | 🔒 | Combinatorics, Prefix Sum, DP |
| 3312 | Sorted GCD Pair Queries | C++ Python | O(rlogr + qlogr) | O(r) | Hard | Number Theory, Freq Table, Prefix Sum, Binary Search | |
| 3317 | Find the Number of Possible Ways for an Event | C++ Python | precompute: O(max_n^2 + max_y * min(max_n, max_x)) runtime: O(min(n, x)) | O(max_n^2 + max_y * min(max_n, max_x)) | Hard | DP, Combinatorics | |
| 3326 | Minimum Division Operations to Make Array Non Decreasing | C++ Python | precompute: O(r) runtime: O(n) | O(r) | Medium | Greedy, Number Theory, Linear Sieve of Eratosthenes | |
| 3339 | Find the Number of K-Even Arrays | C++ Python | O(n) | O(n) | Medium | 🔒 | DP, Stars and Bars, Combinatorics |
| 3345 | Smallest Divisible Digit Product I | C++ Python | O(logn) | O(1) | Easy | Brute Force | |
| 3348 | Smallest Divisible Digit Product II | C++ Python | O(n + logt) | O(1) | Hard | Freq Table, Greedy, Prefix Sum, Number Theory | |
| 3360 | Stone Removal Game | C++ Python | O(1) | O(1) | Easy | Math | |
| 3395 | Subsequences with a Unique Middle Mode I | C++ Python | O(n) | O(n) | Hard | Freq Table, Prefix Sum, Combinatorics | |
| 3405 | Count the Number of Arrays with K Matching Adjacent Elements | C++ Python | O(n + logm) | O(n) | Hard | Combinatorics, Fast Exponentiation | |
| 3411 | Maximum Subarray With Equal Products | C++ Python | precompute: O(r * log(logr)) runtime: O(n * log(logr)) | O(r * log(logr)) | Easy | Number Theory, Linear Sieve of Eratosthenes, Hash Table | |
| 3416 | Subsequences with a Unique Middle Mode II | C++ Python | O(n) | O(n) | Hard | 🔒 | Freq Table, Prefix Sum, Combinatorics |
| 3426 | Manhattan Distances of All Arrangements of Pieces | C++ Python | precompute: O(max(m * n)) runtime: O(1) | O(max(m * n)) | Hard | Combinatorics | |
| 3428 | Maximum and Minimum Sums of at Most Size K Subsequences | C++ Python | O(nlogn) | O(n) | Medium | Sort, Combinatorics, Two Pointers, Sliding Window | |
| 3447 | Assign Elements to Groups with Constraints | C++ Python | O(m + r * logn) | O(r) | Medium | Hash Table, Number Theory | |
| 3448 | Count Substrings Divisible By Last Digit | C++ Python | O(d * n) | O(d) | Hard | DP, Case Works, Math, Freq Table | |
| 3461 | Check If Digits Are Equal in String After Operations I | C++ Python | O(nlogn) | O(1) | Easy | Fast Exponentiation, Luca's Theorem, Simulation | |
| 3463 | Check If Digits Are Equal in String After Operations II | C++ Python | O(nlogn) | O(1) | Hard | Fast Exponentiation, Lucas's Theorem | |
| 3470 | Permutations IV | C++ Python | O(n^2) | O(n) | Hard | Combinatorics | |
| 3483 | Unique 3-Digit Even Numbers | C++ Python | O(n) | O(1) | Easy | Freq Table, Combinatorics | |
| 3492 | Maximum Containers on a Ship | C++ Python | O(1) | O(1) | Easy | Math | |
| 3512 | Minimum Operations to Make Array Sum Divisible by K | C++ Python | O(n) | O(1) | Easy | Math | |
| 3513 | Number of Unique XOR Triplets I | C++ Python | O(logn) | O(1) | Medium | Bit Manipulation, Math | |
| 3516 | Find Closest Person | C++ Python | O(1) | O(1) | Easy | Math | |
| 3519 | Count Numbers with Non-Decreasing Digits | C++ Python | O(n^2) | O(n) | Hard | Math, Stars and Bars, Combinatorics | |
| 3556 | Sum of Largest Prime Substrings | C++ Python | O(n^2 * sqrt(r)) | O(n^2) | Medium | Number Theory, Quick Select | |
| 3560 | Find Minimum Log Transportation Cost | C++ Python | O(1) | O(1) | Easy | Math | |
| 3577 | Count the Number of Computer Unlocking Permutations | C++ Python | O(n) | O(1) | Medium | Combinatorics | |
| 3588 | Find Maximum Area of a Triangle | C++ Python | O(n) | O(n) | Medium | Math, Hash Table | |
| 3596 | Minimum Cost Path with Alternating Directions I | C++ Python | O(1) | O(1) | Medium | 🔒 | Math |
| 3602 | Hexadecimal and Hexatrigesimal Conversion | C++ Python | O(logn) | O(1) | Easy | Math | |
| 3618 | Split Array by Prime Indices | C++ Python | precompute: O(max_n) runtime: O(n) | O(max_n) | Medium | Number Theory, Linear Sieve of Eratosthenes | |
| 3621 | Number of Integers With Popcount-Depth Equal to K I | C++ Python | precompute: O((logr)^2) runtime: O((logn)^2) | O((logr)^2) | Hard | Combinatorics | |
| 3622 | Check Divisibility by Digit Sum and Product | C++ Python | O(logn) | O(1) | Easy | Math | |
| 3623 | Count Number of Trapezoids I | C++ Python | O(n) | O(n) | Medium | Freq Table, Combinatorics | |
| 3624 | Number of Integers With Popcount-Depth Equal to K II | C++ Python | precompute: O((logr) * log(logr)) runtime: O(nlogr + max_k * n + nlogn + qlogn) | O(logr + max_k * n) | Hard | BIT, Fenwick Tree | |
| 3625 | Count Number of Trapezoids II | C++ Python | O(n^2 * logr) | O(n^2) | Hard | Freq Table, Combinatorics | |
| 3648 | Minimum Sensors to Cover Grid | C++ Python | O(1) | O(1) | Medium | Math | |
| 3658 | GCD of Odd and Even Sums | C++ Python | O(1) | O(1) | Easy | Math | |
| 3659 | Partition Array Into K-Distinct Groups | C++ Python | O(n) | O(n) | Medium | Math, Freq Table | |
| 3664 | Two-Letter Card Game | C++ Python | O(n + 26) | O(26) | Medium | Math, Freq Table | |
| 3666 | Minimum Operations to Equalize Binary String | C++ Python | O(n) | O(1) | Hard | Math | |
| 3671 | Sum of Beautiful Subsequences | C++ Python | precompute: O(rlogr) runtime: O(nlogr * (log(nlogr) + logn)) | O(rlogr) | Hard | Number Theory, BIT, Fenwick Tree | |
| 3677 | Count Binary Palindromic Numbers | C++ Python | O(logn) | O(1) | Hard | Bitmasks, Combinatorics | |
| 3697 | Compute Decimal Representation | C++ Python | O(logn) | O(1) | Easy | Math | |
| 3726 | Remove Zeros in Decimal Representation | C++ Python | O(logn) | O(1) | Easy | Math, String | |
| 3731 | Find Missing Elements | C++ Python | O(n + r) | O(n) | Easy | Hash Table | |
| 3745 | Maximize Expression of Three Elements | C++ Python | O(n) | O(1) | Easy | Math | |
| 3747 | Count Distinct Integers After Removing Zeros | C++ Python | O(logn) | O(1) | Medium | Combinatorics | |
| 3754 | Concatenate Non-Zero Digits and Multiply by Sum I | C++ Python | O(logn) | O(1) | Easy | Math | |
| 3765 | Complete Prime Number | C++ Python | O(logn * sqrt(n)) | O(1) | Medium | Prefix Sum, Number Theory | |
| 3770 | Largest Prime from Consecutive Prime Sum | C++ Python | precompute: O(r) runtime: O(logp) | O(sqrt(r)) | Medium | Precompute, Number Theory, Linear Sieve of Eratosthenes, Binary Search | |
| 3783 | Mirror Distance of an Integer | C++ Python | O(logn) | O(1) | Easy | Math | |
| 3789 | Minimum Cost to Acquire Required Items | C++ Python | O(1) | O(1) | Medium | Math | |
| 3790 | Smallest All-Ones Multiple | C++ Python | O(k) | O(1) | Medium | duplicate of Smallest Integer Divisible by K | Math |
| 3798 | Largest Even Number | C++ Python | O(n) | O(1) | Easy | Math | |
| 3800 | Minimum Cost to Make Two Binary Strings Equal | C++ Python | O(n) | O(1) | Medium | Math | |
| 3817 | Good Indices in a Digit String | C++ Python | O(n) | O(1) | Medium | 🔒 | Math, Sliding Window |
| 3821 | Find Nth Smallest Integer With K One Bits | C++ Python | ctor: O(r^2) runtime: O(r) | O(r^2) | Hard | DP, Combinatorics | |
| 3855 | Sum of K-Digit Numbers in a Range | C++ Python | O(logr) | O(1) | Hard | Math | |
| 3857 | Minimum Cost to Split into Ones | C++ Python | O(1) | O(1) | Medium | Combinatorics | |
| 3870 | Count Commas in Range | C++ Python | O(logn) | O(1) | Easy | Math | |
| 3871 | Count Commas in Range II | C++ Python | O(logn) | O(1) | Medium | Math | |
| 3881 | Direction Assignments with Exactly K Visible People | C++ Python | O(n) | O(n) | Medium | Combinatorics | |
| 3895 | Count Digit Appearances | C++ Python | O(nlogr) | O(1) | Medium | Math | |
| 3896 | Count Digit Appearances | C++ Python | precompute: O(r), runtime: O(nlogn) | O(r) | Medium | Number Theory, Linear Sieve of Eratosthenes, Prime Gap, Binary Search | |
| 3899 | Angles of a Triangle | C++ Python | O(1) | O(1) | Medium | Math, Law of Cosines | |
| 3908 | Valid Digit Number | C++ Python | O(logn) | O(1) | Easy | Math | |
| 3927 | Minimize Array Sum Using Divisible Replacements | C++ Python | O(n + rlogr) | O(r) | Medium | Number Theory | |
| 3954 | Sum of Compatible Numbers in Range I | C++ Python | O(log(n + k)) | O(1) | Easy | Bitmasks, Combinatorics, Simulation | |
| 3958 | Minimum Cost to Split into Ones II | C++ Python | O(1) | O(1) | Medium | 🔒 | Math, Invariant |
| 3959 | Check Good Integer | C++ Python | O(logn) | O(1) | Easy | Math |
Sort
Two Pointers
| # | Title | Solution | Time | Space | Difficulty | Tag | Note |
|---|---|---|---|---|---|---|---|
| 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 of Find 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 | |
| 3740 | Minimum Distance Between Three Equal Elements I | C++ Python | O(n) | O(n) | Easy | Hash Table, Two Pointers, Sliding Window | |
| 3741 | Minimum Distance Between Three Equal Elements II | C++ Python | O(n) | O(n) | Medium | Hash Table, Two Pointers, Sliding Window | |
| 3768 | Minimum Inversion Count in Subarrays of Fixed Length | C++ Python | O(nlogn) | O(n) | Hard | Sort, Coordinate Compression, BIT, Fenwick Tree, Two Pointers, Sliding Window | |
| 3795 | Minimum Subarray Length With Distinct Sum At Least K | C++ Python | O(n) | O(n) | Medium | Freq Table, Two Pointers, Sliding Window | |
| 3802 | Number of Ways to Paint Sheets | C++ Python | O(mlogm) | O(m) | Hard | 🔒 | Prefix Sum, Two Pointers |
| 3835 | Count Subarrays With Cost Less Than or Equal to K | C++ Python | O(n) | O(n) | Medium | Mono Deque, Two Pointers, Sliding Window | |
| 3844 | Longest Almost-Palindromic Substring | C++ Python | O(n^2) | O(1) | Medium | Two Pointers | |
| 3845 | Maximum Subarray XOR with Bounded Range | C++ Python | O(nlogr) | O(n) | Hard | Two Pointers, Sliding Window, Mono Deque, Bitmasks, Prefix Sum, Trie, Hash Table | |
| 3851 | Maximum Requests Without Violating the Limit | C++ Python | O(nlogn) | O(n) | Medium | 🔒 | Hash Table, Sort, Deque, Two Pointers, Sliding Window |
| 3859 | Count Subarrays With K Distinct Integers | C++ Python | O(n) | O(n) | Hard | Freq Table, Two Pointers, Sliding Window | |
| 3872 | Longest Arithmetic Sequence After Changing At Most One Element | C++ Python | O(n) | O(1) | Medium | Two Pointers | |
| 3874 | Valid Subarrays With Exactly One Peak | C++ Python | O(n) | O(1) | Medium | 🔒 | Combinatorics, Two Pointers |
| 3937 | Minimum Operations to Make Array Modulo Alternating I | C++ Python | O(n + k) | O(k) | Medium | Freq Table, Two Pointers, Sliding Window | |
| 3944 | Minimum Operations to Make Array Modulo Alternating II | C++ Python | O(n + k) | O(k) | Hard | 🔒 | Freq Table, Two Pointers, Sliding Window |
Recursion
| # | Title | Solution | Time | Space | Difficulty | Tag | Note |
|---|
Binary Search
| # | Title | Solution | Time | Space | Difficulty | Tag | Note |
|---|---|---|---|---|---|---|---|
| 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 + * 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 of Longest 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 | |
| 3722 | Lexicographically Smallest String After Reverse | C++ Python | O(nlogn) | O(n) | Medium | String, Brute Force, Binary Search, Rabin-Karp Algorithm, Rolling Hash | |
| 3733 | Minimum Time to Complete All Deliveries | C++ Python | O(logr + logd) | O(1) | Medium | Binary Search | |
| 3735 | Lexicographically Smallest String After Reverse II | C++ Python | O(nlogn) | O(n) | Hard | 🔒 | Binary Search, Rabin-Karp Algorithm, Rolling Hash |
| 3771 | Total Score of Dungeon Runs | C++ Python | O(nlogn) | O(n) | Medium | Prefix Sum, Binary Search | |
| 3807 | Minimum Cost to Repair Edges to Traverse a Graph | C++ Python | O((n + m) * logr) | O(n + m) | Medium | 🔒 | Binary Search, BFS |
| 3824 | Minimum K to Reduce Array Within Limit | C++ Python | O(nlogn + nlogr) | O(1) | Medium | Binary Search | |
| 3825 | Longest Strictly Increasing Subsequence With Non-Zero Bitwise AND | C++ Python | O(logr * nlogn) | O(n) | Medium | Bitmasks, LIS, Longest Increasing Subsequence, Binary Search | |
| 3826 | Minimum Partition Score | C++ Python | O(nlogn + nlogr) | O(n) | Hard | Prefix Sum, DP, Convex Hull Trick, WQS Binary Search, Alien Trick | |
| 3893 | Maximum Team Size with Overlapping Intervals | C++ Python | O(nlogn) | O(n) | Medium | 🔒 | Sort, Binary Search |
| 3911 | K-th Smallest Remaining Even Integer in Subarray Queries | C++ Python | O(n + qlogn) | O(n) | Hard | Prefix Sum, Binary Search | |
| 3920 | Maximize Fixed Points After Deletions | C++ Python | O(nlogn) | O(n) | Hard | Sort, Binary Search, Longest Increasing Subsequence | |
| 3924 | Minimum Threshold Path With Limited Heavy Edges | C++ Python | O((n + e) * loge) | O(n + e) | Hard | Binary Search, 0-1 BFS, Deque | |
| 3929 | Minimum Partition Score II | C++ Python | O(nlogn + nlogr) | O(n) | Hard | 🔒 | Prefix Sum, DP, Convex Hull Trick, WQS Binary Search, Alien Trick |
| 3932 | Count K-th Roots in a Range | C++ Python | O(logr * logk) | O(1) | Medium | Binary Search, Fast Exponentiation | |
| 3934 | Smallest Unique Subarray | C++ Python | O(nlogn) | O(n) | Hard | Binary Search, Rabin-Karp Algorithm, Rolling Hash | |
| 3956 | Maximum Sum of M Non-Overlapping Subarrays I | C++ Python | O(nlogr) | O(n) | Hard | Prefix Sum, DP, Mono Deque, WQS Binary Search, Alien Trick | |
| 3957 | Maximum Sum of M Non-Overlapping Subarrays II | C++ Python | O(nlogr) | O(n) | Hard | Prefix Sum, DP, Mono Deque, WQS Binary Search, Alien Trick |
Binary Search Tree
| # | Title | Solution | Time | Space | Difficulty | Tag | Note |
|---|---|---|---|---|---|---|---|
| 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 |
| 3930 | Power Update After K-th Largest Insertion II | C++ Python | O((n + q) * log(n * q) + q * logr) | O(n + q) | Hard | 🔒 | Sorted List, Ordered Set, Sort, Coordinate Compression, BIT, Fenwick Tree, Fast Exponentiation |
| 3935 | Power Update After K-th Largest Insertion I | C++ Python | O((n + q) * log(n * q) + q * logr) | O(n + q) | Medium | 🔒 | Sorted List, Ordered Set, Sort, Coordinate Compression, BIT, Fenwick Tree, Fast Exponentiation |
Breadth-First Search
Depth-First Search
Backtracking
| # | Title | Solution | Time | Space | Difficulty | Tag | Note |
|---|---|---|---|---|---|---|---|
| 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 | |
| 3955 | Valid Binary Strings With Cost Limit | C++ Python | O(n * 2^n) | O(n) | Medium | Backtracking, Bitmasks |
Dynamic Programming
Greedy
Graph
| # | Title | Solution | Time | Space | Difficulty | Tag | Note |
|---|---|---|---|---|---|---|---|
| 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 of Maximum 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 | |
| 3710 | Maximum Partition Factor | C++ Python | O(n^2 * logn) | O(n^2) | Hard | Graph, Sort, Coordinate Compression, Binary Search, BFS, Greedy, Union Find | |
| 3778 | Minimum Distance Excluding One Maximum Weighted Edge | C++ Python | O(n + elogn) | O(n + e) | Medium | 🔒 | Graph, Dijkstra's Algorithm |
| 3873 | Maximum Points Activated with One Addition | C++ Python | O(n) | O(n) | Hard | Graph, Union Find | |
| 3887 | Incremental Even-Weighted Cycle Queries | C++ Python | O(n + e) | O(n) | Hard | Graph, Union Find | |
| 3910 | Count Connected Subgraphs with Even Node Sum | C++ Python | O((n + e) * 2^n) | O(n + e) | Hard | Graph, Bitmask, DFS | |
| 3928 | Minimum Cost to Buy Apples II | C++ Python | O(n * (n + elogn)) | O(n + e) | Hard | Graph, Dijkstra's Algorithm |
Geometry
| # | Title | Solution | Time | Space | Difficulty | Tag | Note |
|---|---|---|---|---|---|---|---|
| 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 |
Simulation
| # | Title | Solution | Time | Space | Difficulty | Tag | Note |
|---|---|---|---|---|---|---|---|
| 3100 | Water Bottles II | C++ Python | O(sqrt(n)) | O(1) | Medium | Simulation | |
| 3168 | Minimum Number of Chairs in a Waiting Room | C++ Python | O(n) | O(1) | Easy | Simulation | |
| 3175 | Find The First Player to win K Games in a Row | C++ Python | O(n) | O(1) | Medium | Simulation | |
| 3248 | Snake in Matrix | C++ Python | O(c) | O(1) | Medium | Simulation | |
| 3412 | Find Mirror Score of a String | C++ Python | O(n + 26) | O(n + 26) | Medium | Simulation, Hash Table, Stack | |
| 3433 | Count Mentions Per User | C++ Python | O(eloge + e * n) | O(e + n) | Medium | Simulation | |
| 3507 | Minimum Pair Removal to Sort Array I | C++ Python | O(nlogn) | O(n) | Easy | Simulation, Doubly Linked List, Sorted List, BST | |
| 3510 | Minimum Pair Removal to Sort Array II | C++ Python | O(nlogn) | O(n) | Hard | Simulation, Doubly Linked List, Sorted List, BST | |
| 3522 | Calculate Score After Performing Instructions | C++ Python | O(n) | O(n) | Medium | Simulation | |
| 3561 | Resulting String After Adjacent Removals | C++ Python | O(n) | O(1) | Medium | Simulation, Stack | |
| 3597 | Partition String | C++ Python | O(n) | O(t) | Medium | Simulation, Trie | |
| 3608 | Minimum Time for K Connected Components | C++ Python | O(n + eloge) | O(n) | Medium | Backward Simulation, Sort, Union Find | |
| 3609 | Minimum Moves to Reach Target in Grid | C++ Python | O(logtx + logty) | O(1) | Hard | Backward Simulation | |
| 3612 | Process String with Special Operations I | C++ Python | O(r) | O(r) | Medium | Simulation, Deque | |
| 3613 | Minimize Maximum Component Cost | C++ Python | O(n + eloge) | O(n) | Medium | Backward Simulation, Sort, Union Find | |
| 3614 | Process String with Special Operations II | C++ Python | O(n) | O(1) | Hard | Backward Simulation | |
| 3616 | Number of Student Replacements | C++ Python | O(n) | O(1) | Medium | 🔒 | Simulation |
| 3639 | Minimum Time to Activate String | C++ Python | O(n) | O(n) | Medium | Backward Simulation, Doubly Linked List | |
| 3792 | Sum of Increasing Product Blocks | C++ Python | O(n^2) | O(n^2) | Medium | 🔒 | Simulation, Math |
| 3847 | Find the Score Difference in a Game | C++ Python | O(n) | O(1) | Medium | Simulation | |
| 3853 | Merge Close Characters | C++ Python | O(n + 26) | O(26) | Medium | Simulation, Freq Table, Two Pointers, Sliding Window | |
| 3867 | Sum of GCD of Formed Pairs | C++ Python | O(nlogr) | O(n) | Medium | Simulation, Prefix sum, Sort, Two Pointers | |
| 3894 | Traffic Signal Color | C++ Python | O(1) | O(1) | Easy | Simulation |
Constructive Algorithms
| # | Title | Solution | Time | Space | Difficulty | Tag | Note |
|---|---|---|---|---|---|---|---|
| 3139 | Minimum Cost to Equalize Array | C++ Python | O(n) | O(1) | Hard | Constructive Algorithms, Math | |
| 3260 | Find the Largest Palindrome Divisible by K | C++ Python | O(n) | O(1) | Hard | String, Constructive Algorithms, Math | |
| 3311 | Construct 2D Grid Matching Graph Layout | C++ Python | O(n) | O(n) | Hard | Graph, Constructive Algorithms, BFS | |
| 3375 | Minimum Operations to Make Array Values Equal to K | C++ Python | O(n) | O(n) | Easy | Hash Table, Constructive Algorithms | |
| 3680 | Generate Schedule | C++ Python | O(n^2) | O(1) | Medium | Constructive Algorithms | |
| 3875 | Construct Uniform Parity Array I | C++ Python | O(1) | O(1) | Easy | Constructive Algorithms | |
| 3876 | Construct Uniform Parity Array II | C++ Python | O(n) | O(1) | Medium | Constructive Algorithms |
Design
| # | Title | Solution | Time | Space | Difficulty | Tag | Note |
|---|---|---|---|---|---|---|---|
| 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 | |
| 3709 | Design Exam Scores Tracker | C++ Python | ctor: O(1) record: O(1) totalScore: O(logn) | O(n) | Medium | Prefix Sum, Binary Search | |
| 3815 | Design Auction System | C++ Python | ctor: O(1) addBid: O(logn) updateBid: O(logn) removeBid: O(logn) getHighestBidder: O(1) | O(n) | Medium | Hash Table, Heap, Sorted List, BST | |
| 3822 | Design Order Management System | C++ Python | ctor: O(1) addOrder: O(1) modifyOrder: O(1) cancelOrder: O(1) getOrdersAtPrice: O(n) | O(n) | Medium | 🔒 | Hash Table |
| 3829 | Design Ride Sharing System | C++ Python | ctor: O(1) addRider: O(1) addDriver: O(1) matchDriverWithRider: O(1) cancelRider: O(1) | O(n) | Medium | Ordered Dict | |
| 3885 | Design Event Manager | C++ Python | ctor: O(n) updatePriority: O(logn) pollHightest: O(logn) | O(n) | Medium | Sorted List, BST, Heap, Hash Table |
JS
| # | Title | Solution | Time | Space | Difficulty | Tag | Note |
|---|
SQL
PD
| # | Title | Solution | Time | Space | Difficulty | Tag | Note |
|---|