🏋️ Python / Modern C++ Solutions of All 4073 LeetCode Problems (Weekly Update)
C++
5,949
20,998 commits
updated Oct 12, 2026
5.7k+ stars and 2.2k+ forks (ever the top 3 in the field).| # | 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 |
| # | 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 | |
| 4054 | Count Shadow Pairs I | C++ Python | O(n) | O(n) | Medium | Freq Table, Mono Stack | |
| 4055 | Count Shadow Pairs II | C++ Python | O(nlogn) | O(n) | Hard | Coordinate Compression, Merge Sort, Mono Stack |
| # | Title | Solution | Time | Space | Difficulty | Tag | Note |
|---|
| # | 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 | |
| 4004 | Minimum Moves to Balance Circular Array II | C++ Python | O(n^2 * logn) | O(n) | Hard | 🔒, variant of Codeforces Round #13 C | L1 Isotonic Regression, Heap, Greedy, Graph, Min-Cost Max-Flow, MCMF, Successive Shortest Path, SSP, Dijkstra's Algorithm, Johnson Potential |
| # | 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 | |
| 3973 | Distinct Gate Paths to LCA | C++ Python | O(nlogn + qlogn) | O(nlogn) | Hard | 🔒 | DFS, LCA, Binary Lifting |
| 3997 | Count Dominant Nodes in a Binary Tree | C++ Python | O(n) | O(h) | Medium | DFS |
| # | 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 | |
| 3984 | Divisible Game | C++ Python | precompute: O(r) runtime: O(nlogx) | O(r + n) | Medium | Number Theory, Linear Sieve of Eratosthenes, Kadane's Algorithm, Prefix Sum | |
| 3987 | Minimum Total Cost to Process All Elements | C++ Python | O(n) | O(1) | Medium | Math | |
| 3993 | Maximum Value of an Alternating Sequence | C++ Python | O(1) | O(1) | Medium | Math | |
| 3996 | Even Number of Knight Moves | C++ Python | O(1) | O(1) | Easy | Math, Parity | |
| 4002 | Count Valid Sequences | C++ Python | O(n) | O(n) | Medium | Combinatorics, Stars and Bars | |
| 4022 | K-th Digit in Infinite String | C++ Python | O(logk) | O(1) | Medium | Math | |
| 4034 | Minimum Bishop Moves to Reach Target | C++ Python | O(1) | O(1) | Medium | Math | |
| 4035 | Maximum Valid Split Positions I | C++ Python | O(n) | O(n) | Medium | Number Theory, Prefix Sum | |
| 4037 | Maximum Valid Split Positions II | C++ Python | O(n) | O(n) | Hard | Number Theory, Prefix Sum | |
| 4039 | Sum of Decoded Numbers | C++ Python | O(nlogr) | O(1) | Medium | Fast Exponentiation | |
| 4060 | Count Evenly Good Integers | C++ Python | O(logr) | O(1) | Hard | 🔒 | Math |
| 4061 | Minimum Queen Moves to Reach Target | C++ Python | O(1) | O(1) | Easy | Math |
| # | 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 |
| 3969 | Valid Subarrays With Matching Sum Digits I | C++ Python | O(nlogr) | O(n) | Medium | Brute Force, Prefix Sum, Two Pointers, Sliding Window | |
| 3972 | Valid Subarrays With Matching Sum Digits II | C++ Python | O(nlogr) | O(n) | Hard | 🔒 | Prefix Sum, Two Pointers, Sliding Window |
| 3992 | Rearrange String to Avoid Character Pair | C++ Python | O(n) | O(1) | Easy | Two Pointers | |
| 4001 | Aggregate Two Time Series | C++ Python | O(n + m) | O(1) | Medium | Two Pointers | |
| 4031 | Find All Numbers Disappeared in an Array II | C++ Python | O(r) | O(r) | Medium | Sort, Two Pointers, Hash Table | |
| 4032 | Longest Subarray With at Most K Distinct Prime Factors | C++ Python | ctor: O(r) runtime: O(nlogr) | O(r) | Medium | Number Theory, Linear Sieve of Eratosthenes, Freq Table, Two Pointers, Sliding Window | |
| 4033 | Valid K-Unique Subarrays I | C++ Python | O(n + q) | O(n) | Hard | Two Pointers, Sliding Window, Hash Table, Prefix Sum, BIT, Fenwick Tree, Sort, Coordinate Compression, Mo's Algorithm | |
| 4042 | Valid K-Unique Subarrays II | C++ Python | O(n + q) | O(n) | Hard | 🔒 | Two Pointers, Sliding Window, Hash Table, Prefix Sum |
| 4044 | Count Good Cyclic Rotations | C++ Python | O(n) | O(1) | Medium | Two Pointers, Sliding Window | |
| 4067 | Longest Subarray With Restricted Pair Sums | C++ Python | O(n * r) | O(r) | Medium | Freq Table, Two Pointers, Sliding Window |
| # | Title | Solution | Time | Space | Difficulty | Tag | Note |
|---|
| # | 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 + 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 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 | |
| 3971 | Maximum Total Value | C++ Python | O(nlogr) | O(1) | Hard | Binary Search |
| # | 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 |
| # | 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 |
| # | Title | Solution | Time | Space | Difficulty | Tag | Note |
|---|---|---|---|---|---|---|---|
| 3018 | Maximum Number of Removal Queries That Can Be Processed I | C++ Python | O(n^2) | O(n^2) | Hard | 🔒 | DP |
| 3020 | Find the Maximum Number of Elements in Subset | C++ Python | O(n) | O(n) | Medium | Freq Table, DP | |
| 3040 | Maximum Number of Operations With the Same Score II | C++ Python | O(n^2) | O(n^2) | Medium | Memoization | |
| 3041 | Maximize Consecutive Elements in an Array After Modification | C++ Python | O(nlogn) | O(1) | Hard | Sort, DP | |
| 3077 | Maximum Strength of K Disjoint Subarrays | C++ Python | O(k * n) | O(n) | Hard | DP, Greedy, Kadane's Algorithm | |
| 3082 | Find the Sum of the Power of All Subsequences | C++ Python | O(n * k) | O(k) | Hard | DP, Combinatorics | |
| 3098 | Find the Sum of Subsequence Powers | C++ Python | O(n^3 * k) | O(n^2) | Hard | DP, Prefix Sum, Two Pointers | |
| 3101 | Count Alternating Subarrays | C++ Python | O(n) | O(1) | Medium | DP | |
| 3117 | Minimum Sum of Values by Dividing Array | [C++](./C++/minimum-sum-of-values-by-dividi |
Truncated — view the full README on GitHub.
380 followers · starred Apr 2022
46 followers · starred Aug 2022
243 followers · starred Dec 2020
🏋️ Python / Modern C++ Solutions of All 4073 LeetCode Problems (Weekly Update)
C++
5,949
20,998 commits
updated Oct 12, 2026
5.7k+ stars and 2.2k+ forks (ever the top 3 in the field).| # | 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 |
| # | 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 | |
| 4054 | Count Shadow Pairs I | C++ Python | O(n) | O(n) | Medium | Freq Table, Mono Stack | |
| 4055 | Count Shadow Pairs II | C++ Python | O(nlogn) | O(n) | Hard | Coordinate Compression, Merge Sort, Mono Stack |
| # | Title | Solution | Time | Space | Difficulty | Tag | Note |
|---|
| # | 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 | |
| 4004 | Minimum Moves to Balance Circular Array II | C++ Python | O(n^2 * logn) | O(n) | Hard | 🔒, variant of Codeforces Round #13 C | L1 Isotonic Regression, Heap, Greedy, Graph, Min-Cost Max-Flow, MCMF, Successive Shortest Path, SSP, Dijkstra's Algorithm, Johnson Potential |
| # | 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 | |
| 3973 | Distinct Gate Paths to LCA | C++ Python | O(nlogn + qlogn) | O(nlogn) | Hard | 🔒 | DFS, LCA, Binary Lifting |
| 3997 | Count Dominant Nodes in a Binary Tree | C++ Python | O(n) | O(h) | Medium | DFS |
| # | 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 | |
| 3984 | Divisible Game | C++ Python | precompute: O(r) runtime: O(nlogx) | O(r + n) | Medium | Number Theory, Linear Sieve of Eratosthenes, Kadane's Algorithm, Prefix Sum | |
| 3987 | Minimum Total Cost to Process All Elements | C++ Python | O(n) | O(1) | Medium | Math | |
| 3993 | Maximum Value of an Alternating Sequence | C++ Python | O(1) | O(1) | Medium | Math | |
| 3996 | Even Number of Knight Moves | C++ Python | O(1) | O(1) | Easy | Math, Parity | |
| 4002 | Count Valid Sequences | C++ Python | O(n) | O(n) | Medium | Combinatorics, Stars and Bars | |
| 4022 | K-th Digit in Infinite String | C++ Python | O(logk) | O(1) | Medium | Math | |
| 4034 | Minimum Bishop Moves to Reach Target | C++ Python | O(1) | O(1) | Medium | Math | |
| 4035 | Maximum Valid Split Positions I | C++ Python | O(n) | O(n) | Medium | Number Theory, Prefix Sum | |
| 4037 | Maximum Valid Split Positions II | C++ Python | O(n) | O(n) | Hard | Number Theory, Prefix Sum | |
| 4039 | Sum of Decoded Numbers | C++ Python | O(nlogr) | O(1) | Medium | Fast Exponentiation | |
| 4060 | Count Evenly Good Integers | C++ Python | O(logr) | O(1) | Hard | 🔒 | Math |
| 4061 | Minimum Queen Moves to Reach Target | C++ Python | O(1) | O(1) | Easy | Math |
| # | 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 |
| 3969 | Valid Subarrays With Matching Sum Digits I | C++ Python | O(nlogr) | O(n) | Medium | Brute Force, Prefix Sum, Two Pointers, Sliding Window | |
| 3972 | Valid Subarrays With Matching Sum Digits II | C++ Python | O(nlogr) | O(n) | Hard | 🔒 | Prefix Sum, Two Pointers, Sliding Window |
| 3992 | Rearrange String to Avoid Character Pair | C++ Python | O(n) | O(1) | Easy | Two Pointers | |
| 4001 | Aggregate Two Time Series | C++ Python | O(n + m) | O(1) | Medium | Two Pointers | |
| 4031 | Find All Numbers Disappeared in an Array II | C++ Python | O(r) | O(r) | Medium | Sort, Two Pointers, Hash Table | |
| 4032 | Longest Subarray With at Most K Distinct Prime Factors | C++ Python | ctor: O(r) runtime: O(nlogr) | O(r) | Medium | Number Theory, Linear Sieve of Eratosthenes, Freq Table, Two Pointers, Sliding Window | |
| 4033 | Valid K-Unique Subarrays I | C++ Python | O(n + q) | O(n) | Hard | Two Pointers, Sliding Window, Hash Table, Prefix Sum, BIT, Fenwick Tree, Sort, Coordinate Compression, Mo's Algorithm | |
| 4042 | Valid K-Unique Subarrays II | C++ Python | O(n + q) | O(n) | Hard | 🔒 | Two Pointers, Sliding Window, Hash Table, Prefix Sum |
| 4044 | Count Good Cyclic Rotations | C++ Python | O(n) | O(1) | Medium | Two Pointers, Sliding Window | |
| 4067 | Longest Subarray With Restricted Pair Sums | C++ Python | O(n * r) | O(r) | Medium | Freq Table, Two Pointers, Sliding Window |
| # | Title | Solution | Time | Space | Difficulty | Tag | Note |
|---|
| # | 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 + 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 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 | |
| 3971 | Maximum Total Value | C++ Python | O(nlogr) | O(1) | Hard | Binary Search |
| # | 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 |
| # | 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 |
| # | Title | Solution | Time | Space | Difficulty | Tag | Note |
|---|---|---|---|---|---|---|---|
| 3018 | Maximum Number of Removal Queries That Can Be Processed I | C++ Python | O(n^2) | O(n^2) | Hard | 🔒 | DP |
| 3020 | Find the Maximum Number of Elements in Subset | C++ Python | O(n) | O(n) | Medium | Freq Table, DP | |
| 3040 | Maximum Number of Operations With the Same Score II | C++ Python | O(n^2) | O(n^2) | Medium | Memoization | |
| 3041 | Maximize Consecutive Elements in an Array After Modification | C++ Python | O(nlogn) | O(1) | Hard | Sort, DP | |
| 3077 | Maximum Strength of K Disjoint Subarrays | C++ Python | O(k * n) | O(n) | Hard | DP, Greedy, Kadane's Algorithm | |
| 3082 | Find the Sum of the Power of All Subsequences | C++ Python | O(n * k) | O(k) | Hard | DP, Combinatorics | |
| 3098 | Find the Sum of Subsequence Powers | C++ Python | O(n^3 * k) | O(n^2) | Hard | DP, Prefix Sum, Two Pointers | |
| 3101 | Count Alternating Subarrays | C++ Python | O(n) | O(1) | Medium | DP | |
| 3117 | Minimum Sum of Values by Dividing Array | [C++](./C++/minimum-sum-of-values-by-dividi |
Truncated — view the full README on GitHub.
380 followers · starred Apr 2022
46 followers · starred Aug 2022
243 followers · starred Dec 2020