- 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.
- Bit Manipulation
- Array
- String
- Linked List
- Stack
- Queue
- Binary Heap
- Tree
- Hash Table
- Math
- Sort
- Two Pointers
- Recursion
- Binary Search
- Binary Search Tree
- Breadth-First Search
- Depth-First Search
- Backtracking
- Dynamic Programming
- Greedy
- Graph
- Geometry
- Simulation
- Constructive Algorithms
- Design
| # | Title | Solution | Time | Space | Difficulty | Tag | Note |
|---|---|---|---|---|---|---|---|
| 3064 | Guess the Number Using Bitwise Questions I | C++ Python | O(logn) | O(1) | Medium | π | Bit Manipulation |
| 3094 | Guess the Number Using Bitwise Questions II | C++ Python | O(logr) | O(1) | Medium | π | Bit Manipulation |
| 3125 | Maximum Number That Makes Result of Bitwise AND Zero | C++ Python | O(1) | O(1) | Medium | π | Bit Manipulation |
| 3133 | Minimum Array End | C++ Python | O(logn) | O(1) | Medium | Bit Manipulation | |
| 3199 | Count Triplets with Even XOR Set Bits I | C++ Python | O(nlogr) | O(1) | Easy | π | Brute Force, Bit Manipulation, Parity |
| 3215 | Count Triplets with Even XOR Set Bits II | C++ Python | O(nlogr) | O(1) | Medium | π | Bit Manipulation, Parity |
| 3226 | Number of Bit Changes to Make Two Integers Equal | C++ Python | O(logn) | O(1) | Easy | Bit Manipulation | |
| 3289 | The Two Sneaky Numbers of Digitville | C++ Python | O(n) | O(1) | Easy | Bit Manipulation | |
| 3304 | Find the K-th Character in String Game I | C++ Python | O(n) | O(1) | Easy | Bitmasks | |
| 3307 | Find the K-th Character in String Game II | C++ Python | O(1) | O(1) | Hard | Bitmasks | |
| 3314 | Construct the Minimum Bitwise Array I | C++ Python | O(n) | O(1) | Easy | Bit Manipulation | |
| 3315 | Construct the Minimum Bitwise Array II | C++ Python | O(n) | O(1) | Medium | Bit Manipulation | |
| 3344 | Maximum Sized Array | C++ Python | precompute: O(max_s^(1/5) * log(max_s)) runtime: O(log(max_s)) |
O(max_s^(1/5)) | Medium | π | Precompute, Bitmasks, Combinatorics, Binary Search |
| 3370 | Smallest Number With All Set Bits | C++ Python | O(1) | O(1) | Easy | Bit Manipulation | |
| 3566 | Partition Array into Two Equal Product Subsets | C++ Python | O(n * 2^n) | O(1) | Medium | Bitmasks | |
| 3632 | Subarrays with XOR at Least K | C++ Python | O(nlogr) | O(t) | Hard | π | Bitmasks, Prefix Sum, Trie |
| 3646 | Next Special Palindrome Number | C++ Python | precompute: O(9 * 2^9 + 16 * p + plogp) runtime: O(logp) |
O(p) | Hard | Precompute, Bitmasks, Sort, Binary Search | |
| 3702 | Longest Subsequence With Non-Zero Bitwise XOR | C++ Python | O(n) | O(1) | Medium | Bitmasks | |
| 3750 | Minimum Number of Flips to Reverse Binary String | C++ Python | O(logn) | O(1) | Easy | Bitmasks | |
| 3766 | Minimum Operations to Make Binary Palindrome | C++ Python | precompute: O(sqrt(r) * logr) runtime: O(r) |
O(r) | Medium | Precompute, Bitmasks, Two Pointers | |
| 3769 | Sort Integers by Binary Reflection | C++ Python | O(nlogr + nlogn) | O(n) | Easy | Sort, Bitmasks | |
| 3782 | Last Remaining Integer After Alternating Deletion Operations | C++ Python | O(1) | O(1) | Hard | Bitmasks, Simulation | |
| 3827 | Count Monobit Integers | C++ Python | O(logn) | O(1) | Easy | Bitmasks |
| # | 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 |
| # | 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 |
| # | 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 |
| # | Title | Solution | Time | Space | Difficulty | Tag | Note |
|---|---|---|---|---|---|---|---|
| 3005 | Count Elements With Maximum Frequency | C++ Python | O(n) | O(n) | Easy | Freq Table | |
| 3039 | Apply Operations to Make String Empty | C++ Python | O(n) | O(1) | Medium | Freq Table | |
| 3044 | Most Frequent Prime | C++ Python | precompute: O(10^MAX_N_M) runtime: O(n * m * (n + m)) |
O(10^MAX_N_M + n * m * (n + m)) | Medium | Number Theory, Linear Sieve of Eratosthenes, Freq Table |
|
| 3046 | Split the Array | C++ Python | O(n) | O(n) | Easy | Freq Table | |
| 3078 | Match Alphanumerical Pattern in Matrix I | C++ Python | O(n * m * r * c) | O(1) | Medium | π | Brute Force, Hash Table |
| 3083 | Existence of a Substring in a String and Its Reverse | C++ Python | O(n) | O(min(n, 26^2)) | Easy | Hash Table | |
| 3120 | Count the Number of Special Characters I | C++ Python | O(n + 26) | O(26) | Easy | Hash Table | |
| 3121 | Count the Number of Special Characters II | C++ Python | O(n + 26) | O(26) | Medium | Hash Table | |
| 3137 | Minimum Number of Operations to Make Word K-Periodic | C++ Python | O(n) | O(n) | Medium | Freq Table | |
| 3138 | Minimum Length of Anagram Concatenation | C++ Python | O(sqrt(n) * n + 26 * nlogn) | O(26) | Medium | Number Theory, Freq Table | |
| 3143 | Maximum Points Inside the Square | C++ Python | O(n + 26) | O(26) | Medium | Hash Table | |
| 3146 | Permutation Difference between Two Strings | C++ Python | O(n + 26) | O(26) | Easy | Hash Table | |
| 3158 | Find the XOR of Numbers Which Appear Twice | C++ Python | O(n) | O(n) | Easy | Hash Table | |
| 3160 | Find the Number of Distinct Colors Among the Balls | C++ Python | O(q) | O(q) | Medium | Freq Table | |
| 3167 | Better Compression of String | C++ Python | O(n + 26) | O(26) | Medium | π | Freq Table, Counting Sort |
| 3184 | Count Pairs That Form a Complete Day I | C++ Python | O(n + 24) | O(24) | Easy | Freq Table | |
| 3185 | Count Pairs That Form a Complete Day II | C++ Python | O(n + 24) | O(24) | Medium | Freq Table | |
| 3223 | Minimum Length of String After Operations | C++ Python | O(n + 26) | O(26) | Medium | Freq Table | |
| 3237 | Alt and Tab Simulation | C++ Python | O(n) | O(n) | Medium | π | Hash Table |
| 3238 | Find the Number of Winning Players | C++ Python | O(p) | O(min(n * c, p) | Easy | Freq Table | |
| 3245 | Alternating Groups III | C++ Python | O(nlogn + qlogn) | O(n) | Hard | BST, Sorted List, Freq Table, BIT, Fenwick Tree | |
| 3295 | Report Spam Message | C++ Python | O(n + m) | O(m) | Medium | Hash Table | |
| 3365 | Rearrange K Substrings to Form Target String | C++ Python | O(n) | O(n) | Medium | Freq Table | |
| 3371 | Identify the Largest Outlier in an Array | C++ Python | O(n) | O(n) | Medium | Freq Table | |
| 3396 | Minimum Number of Operations to Make Elements in Array Distinct | C++ Python | O(n + r) | O(r) | Easy | Freq Table | |
| 3404 | Count Special Subsequences | C++ Python | O(n^2) | O(n^2) | Medium | Freq Table, Number Theory | |
| 3438 | Find Valid Pair of Adjacent Digits in String | C++ Python | O(n) | O(1) | Easy | Freq Table | |
| 3442 | Maximum Difference Between Even and Odd Frequency I | C++ Python | O(n + 26) | O(26) | Easy | Freq Table | |
| 3450 | Maximum Students on a Single Bench | C++ Python | O(n) | O(n) | Easy | π | Hash Table, Unordered Set |
| 3471 | Find the Largest Almost Missing Integer | C++ Python | O(n) | O(n) | Easy | Freq Table | |
| 3487 | Maximum Unique Subarray Sum After Deletion | C++ Python | O(n) | O(n) | Easy | Hash Table | |
| 3488 | Closest Equal Element Queries | C++ Python | O(n) | O(n) | Medium | Hash Table | |
| 3527 | Find the Most Common Response | C++ Python | O(n * l) | O(n * l) | Medium | Hash Table, Freq Table | |
| 3541 | Find Most Frequent Vowel and Consonant | C++ Python | O(n + 26) | O(26) | Easy | Freq Table | |
| 3572 | Maximize YβSum by Picking a Triplet of Distinct XβValues | C++ Python | O(n) | O(n) | Medium | Hash Table, Quick Select | |
| 3581 | Count Odd Letters from Number | C++ Python | O(logn) | O(26) | Easy | π | Freq Table |
| 3591 | Check if Any Element Has Prime Frequency | C++ Python | precompute: O(MAX_N) runtime: O(n) |
O(MAX_N) | Easy | Freq Table, Number Theory, Linear Sieve of Eratosthenes |
|
| 3636 | Threshold Majority Queries | C++ Python | O(nlogn + qlogq + (n + q) * sqrt(n) * logn) | O(q + n) | Hard | Sort, Coordinate Compression, Sqrt Decomposition, Mo's Algorithm, Freq Table, Sorted List, BST |
|
| 3662 | Filter Characters by Frequency | C++ Python | O(n + 26) | O(26) | Easy | π | Freq Table |
| 3663 | Find The Least Frequent Digit | C++ Python | O(logn + 10) | O(10) | Easy | Freq Table | |
| 3668 | Restore Finishing Order | C++ Python | O(n + min(8, n)) | O(min(8, n)) | Easy | Hash Table | |
| 3678 | Smallest Absent Positive Greater Than Average | C++ Python | O(n) | O(n) | Easy | Hash Table | |
| 3682 | Minimum Index Sum of Common Elements | C++ Python | O(n + m) | O(n) | Medium | π | Hash Table |
| 3692 | Majority Frequency Characters | C++ Python | O(n + 26) | O(26) | Easy | Freq Table | |
| 3694 | Distinct Points Reachable After Substring Removal | C++ Python | O(n) | O(n) | Medium | Hash Table | |
| 3712 | Sum of Elements With Frequency Divisible by K | C++ Python | O(n) | O(n) | Easy | Freq Table | |
| 3713 | Longest Balanced Substring I | C++ Python | O(n * (a + n)) | O(a) | Medium | Freq Table | |
| 3714 | Longest Balanced Substring II | C++ Python | O(n) | O(n) | Medium | Hash Table, Prefix Sum | |
| 3718 | Smallest Missing Multiple of K | C++ Python | O(n) | O(n) | Easy | Hash Table | |
| 3728 | Stable Subarrays With Equal Boundary and Interior Sum | C++ Python | O(n) | O(n) | Medium | Freq Table, Prefix Sum | |
| 3729 | Count Distinct Subarrays Divisible by K in Sorted Array | C++ Python | O(n) | O(min(n, k)) | Hard | Freq Table, Prefix Sum | |
| 3755 | Find Maximum Balanced XOR Subarray Length | C++ Python | O(n) | O(n) | Medium | Hash Table, Prefix Sum | |
| 3760 | Maximum Substrings With Distinct Start | C++ Python | O(n + 26) | O(26) | Medium | Hash Table | |
| 3761 | Minimum Absolute Distance Between Mirror Pairs | C++ Python | O(nlogr) | O(n) | Medium | Hash Table | |
| 3773 | Maximum Number of Equal Length Runs | C++ Python | O(n) | O(sqrt(n)) | Medium | π | Freq Table |
| 3779 | Minimum Number of Operations to Have Distinct Elements | C++ Python | O(n) | O(n) | Medium | Hash Table | |
| 3784 | Minimum Deletion Cost to Make All Characters Equal | C++ Python | O(n + 26) | O(26) | Medium | Freq Table | |
| 3803 | Count Residue Prefixes | C++ Python | O(n + 26) | O(26) | Easy | Hash Table | |
| 3804 | Number of Centered Subarrays | C++ Python | O(n^2) | O(n) | Medium | Hash Table | |
| 3805 | Count Caesar Cipher Pairs | C++ Python | O(n * m) | O(n * m) | Medium | Freq Table | |
| 3810 | Minimum Operations to Reach Target Array | C++ Python | O(n) | O(n) | Medium | Hash Table |
| # | 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 |
| # | Title | Solution | Time | Space | Difficulty | Tag | Note |
|---|---|---|---|---|---|---|---|
| 3011 | Find if Array Can Be Sorted | C++ Python | O(n) | O(1) | Medium | Sort | |
| 3025 | Find the Number of Ways to Place People I | C++ Python | O(n^2) | O(1) | Medium | Sort, Array | |
| 3027 | Find the Number of Ways to Place People II | C++ Python | O(n^2) | O(1) | Hard | Sort, Array | |
| 3081 | Replace Question Marks in String to Minimize Its Value | C++ Python | O(n + 26 * log(26)) | O(n + 26) | Medium | Greedy, Counting Sort, Heap, Prefix Sum | |
| 3132 | Find the Integer Added to Array II | C++ Python | O(n) | O(n) | Medium | Sort, Paritial Sort, Freq Table | |
| 3169 | Count Days Without Meetings | C++ Python | O(nlogn) | O(1) | Medium | Sort | |
| 3194 | Minimum Average of Smallest and Largest Elements | C++ Python | O(nlogn) | O(1) | Easy | Sort | |
| 3309 | Maximum Possible Number by Binary Concatenation | C++ Python | O(n * logr * logn) | O(nlogr) | Medium | Sort, Brute Force | |
| 3394 | Check if Grid can be Cut into Sections | C++ Python | O(nlogn) | O(1) | Medium | Sort, Merge Intervals | |
| 3431 | Minimum Unlocked Indices to Sort Nums | C++ Python | O(n) | O(1) | Medium | Sort | |
| 3551 | Minimum Swaps to Sort by Digit Sum | C++ Python | O(nlogr + nlogn) | O(n) | Medium | Sort | |
| 3631 | Sort Threats by Severity and Exploitability | C++ Python | O(nlogn) | O(1) | Medium | π | Sort |
| 3644 | Maximum K to Sort a Permutation | C++ Python | O(n) | O(1) | Medium | Sort, Bitmasks, Constructive Algorithms | |
| 3667 | Sort Array By Absolute Value | C++ Python | O(n + r) | O(n + r) | Easy | π | Sort |
| 3759 | Count Elements With at Least K Greater Values | C++ Python | O(n) | O(1) | Medium | Sort, Quick Select | |
| 3780 | Maximum Sum of Three Numbers Divisible by Three | C++ Python | O(n) | O(1) | Medium | Sort, Math | |
| 3799 | Word Squares II | C++ Python | O(n^4) | O(1) | Medium | Sort, Brute Force, Hash Table |
| # | 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 |
| # | 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 |
| # | 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 |
| # | Title | Solution | Time | Space | Difficulty | Tag | Note |
|---|---|---|---|---|---|---|---|
| 3157 | Find the Level of Tree with Minimum Sum | C++ Python | O(n) | O(w) | Medium | π | BFS |
| 3286 | Find a Safe Walk Through a Grid | C++ Python | O(m * n) | O(m * n) | Medium | variant of Minimum Obstacle Removal to Reach Corner | 0-1 BFS, Deque |
| 3373 | Maximize the Number of Target Nodes After Connecting Trees II | C++ Python | O(n + m) | O(n + m) | Hard | BFS | |
| 3528 | Unit Conversion I | C++ Python | O(n) | O(n) | Medium | BFS | |
| 3535 | Unit Conversion II | C++ Python | O(n + qlogm) | O(n) | Medium | π | BFS, Fast Exponentiation |
| 3552 | Grid Teleportation Traversal | C++ Python | O(m * n) | O(m * n) | Medium | 0-1 BFS, Deque | |
| 3568 | Minimum Moves to Clean the Classroom | C++ Python | O(m * n * 2^l) | O(m * n * 2^l) | Medium | BFS, Bitmasks | |
| 3619 | Count Islands With Total Value Divisible by K | C++ Python | O(m * n) | O(m + n) | Medium | BFS, Flood Fill | |
| 3629 | Minimum Jumps to Reach End via Prime Teleportation | C++ Python | precompute: O(r) runtime: O(nlogr) |
O(r + nlogr) | Medium | Number Theory, Linear Sieve of Eratosthenes, BFS |
|
| 3690 | Split and Merge Array Transformation | C++ Python | O(n^4 * n!) | O(n * n!) | Medium | BFS | |
| 3695 | Maximize Alternating Sum Using Swaps | C++ Python | O(n + s) | O(n + s) | Hard | BFS, Flood Fill, Quick Select | |
| 3786 | Total Sum of Interaction Cost in Tree Groups | C++ Python | O(nlogn) | O(n) | Hard | BFS, DFS, Small-to-Large Merging | |
| 3787 | Find Diameter Endpoints of a Tree | C++ Python | O(n) | O(n) | Medium | π | BFS, Tree Diameter |
| 3820 | Pythagorean Distance Nodes in a Tree | C++ Python | O(n) | O(n) | Medium | BFS | |
| 3831 | Median of a Binary Search Tree Level | C++ Python | O(n) | O(n) | Medium | π | BFS |
| # | Title | Solution | Time | Space | Difficulty | Tag | Note |
|---|---|---|---|---|---|---|---|
| 3004 | Maximum Subtree of the Same Color | C++ Python | O(n) | O(h) | Medium | π | DFS |
| 3067 | Count Pairs of Connectable Servers in a Weighted Tree Network | C++ Python | O(n^2) | O(n) | Medium | DFS, BFS | |
| 3203 | Find Minimum Diameter After Merging Two Trees | C++ Python | O(n + m) | O(n + m) | Hard | variant of Tree Diameter | DFS, BFS, Tree DP, Tree Diameter |
| 3249 | Count the Number of Good Nodes | C++ Python | O(n) | O(h) | Medium | DFS | |
| 3319 | K-th Largest Perfect Subtree Size in Binary Tree | C++ Python | O(n) | O(n) | Medium | DFS, Quick Select | |
| 3327 | Check if DFS Strings Are Palindromes | C++ Python | O(n) | O(n) | Hard | DFS, Manacher's Algorithm |
|
| 3331 | Find Subtree Sizes After Changes | C++ Python | O(n) | O(n) | Medium | DFS, Hash Table | |
| 3367 | Maximize Sum of Weights after Edge Removals | C++ Python | O(n) | O(n) | Hard | DFS, Quick Select | |
| 3590 | Kth Smallest Path XOR Sum | C++ Python | O(n * (logn)^2 + qlogn) | O(n + q) | Hard | DFS, Small-to-Large Merging, Ordered Set, Sorted List | |
| 3593 | Minimum Increments to Equalize Leaf Paths | C++ Python | O(n) | O(n) | Medium | DFS | |
| 3607 | Power Grid Maintenance | C++ Python | O(c + n + q) | O(c + n) | Medium | DFS, Flood Fill, Sort |
| # | 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 |
| # | 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++ Python | O(n * m * logr) | O(n + logr) | Hard | Memoization, DP, RMQ, Sparse Table, Mono Deque, Two Pointers | |
| 3122 | Minimum Number of Operations to Satisfy Conditions | C++ Python | O(n * (m + 10)) | O(10) | Medium | DP | |
| 3129 | Find All Possible Stable Binary Arrays I | C++ Python | O(n * m) | O(n * m) | Medium | DP | |
| 3130 | Find All Possible Stable Binary Arrays II | C++ Python | O(n * m) | O(n * m) | Hard | DP | |
| 3141 | Maximum Hamming Distances | C++ Python | O(m * 2^m) | O(2^m) | Hard | π | Bitmasks, BFS, Knapsack DP |
| 3144 | Minimum Substring Partition of Equal Character Frequency | C++ Python | O(n * (n + 26)) | O(n + 26) | Medium | DP, Freq Table | |
| 3148 | Maximum Difference Score in a Grid | C++ Python | O(m * n) | O(1) | Medium | DP | |
| 3149 | Find the Minimum Cost Array Permutation | C++ Python | O((n-1)^2 * 2^(n-1)) | O((n-1) * 2^(n-1)) | Hard | DP, Backtracing | |
| 3176 | Find the Maximum Length of a Good Subsequence I | C++ Python | O(n * k) | O(n * k) | Medium | DP | |
| 3177 | Find the Maximum Length of a Good Subsequence II | C++ Python | O(n * k) | O(n * k) | Hard | DP | |
| 3180 | Maximum Total Reward Using Operations I | C++ Python | O(n * k) | O(n * k) | Medium | Sort, DP, Bitset | |
| 3181 | Maximum Total Reward Using Operations II | C++ Python | O(n * k) | O(n * k) | Hard | Sort, DP, Bitset | |
| 3186 | Maximum Total Damage With Spell Casting | C++ Python | O(nlogn) | O(n) | Medium | Sort, DP, Two Pointers, Sliding window, Deque | |
| 3193 | Count the Number of Inversions | C++ Python | O(n * k) | O(n + k) | Hard | variant of K Inverse Pairs Array | Knapsack DP, Combinatorics, Sliding Window, Two Pointers |
| 3196 | Maximize Total Cost of Alternating Subarrays | C++ Python | O(n) | O(1) | Medium | DP | |
| 3197 | Find the Minimum Area to Cover All Ones II | C++ Python | O(max(n, m)^2) | O(max(n, m)^2) | Hard | Array, Brute Force, Prefix Sum, Binary Search, RMQ, Sparse Table, DP | |
| 3201 | Find the Maximum Length of Valid Subsequence I | C++ Python | O(n) | O(1) | Medium | Brute Force, DP | |
| 3202 | Find the Maximum Length of Valid Subsequence II | C++ Python | O(n * k) | O(k) | Medium | DP | |
| 3209 | Number of Subarrays With AND Value of K | C++ Python | O(nlogr) | O(logr) | Hard | variant of Find Subarray With Bitwise OR Closest to K | DP |
| 3212 | Count Submatrices With Equal Frequency of X and Y | C++ Python | O(n * m) | O(n * m) | Medium | DP | |
| 3213 | Construct String with Minimum Cost | C++ Python | O(n^2 + w * l) | O(t) | Hard | DP, Trie | |
| 3225 | Maximum Score From Grid Operations | C++ Python | O(n^3) | O(n) | Hard | Prefix Sum, DP | |
| 3241 | Time Taken to Mark All Nodes | C++ Python | O(n) | O(n) | Hard | Tree DP, BFS, DFS | |
| 3253 | Construct String with Minimum Cost (Easy) | C++ Python | O(n * w * l) | O(l) | Medium | π | DP, Trie |
| 3259 | Maximum Energy Boost From Two Drinks | C++ Python | O(n) | O(1) | Medium | DP | |
| 3269 | Constructing Two Increasing Arrays | C++ Python | O(m * n) | O(min(m, n)) | Hard | π | DP |
| 3277 | Maximum XOR Score Subarray Queries | C++ Python | O(n^2 + q) | O(n^2) | Hard | DP | |
| 3283 | Maximum Number of Moves to Kill All Pawns | C++ Python | O(p^2 * 2^p) | O(p * 2^p) | Hard | BFS, Bitmasks, DP | |
| 3287 | Find the Maximum Sequence Value of Array | C++ Python | O(n * r + r^2) | O(r) | Hard | Bitmasks, Prefix Sum, DP | |
| 3290 | Maximum Multiplication Score | C++ Python | O(n) | O(1) | Medium | DP | |
| 3291 | Minimum Number of Valid Strings to Form Target I | C++ Python | O(n + w * l) | O(n + t) | Medium | KMP, Rabin-Karp Algorithm, Rolling Hash, Hash Table, Two Pointers, Sliding Window, DP, Aho-Corasick Automata, Trie |
|
| 3292 | Minimum Number of Valid Strings to Form Target II | C++ Python | O(n + w * l) | O(n + t) | Hard | KMP, Rabin-Karp Algorithm, Rolling Hash, Hash Table, Two Pointers, Sliding Window, DP, Aho-Corasick Automata, Trie |
|
| 3313 | Find the Last Marked Nodes in Tree | C++ Python | O(n) | O(n) | Hard | π, variant of Time Taken to Mark All Nodes | BFS, DFS, Tree DP, Tree Diameter |
| 3316 | Find Maximum Removals From Source String | C++ Python | O(n * m) | O(n + m) | Medium | DP | |
| 3320 | Count The Number of Winning Sequences | C++ Python | O(n^2) | O(n) | Hard | DP | |
| 3332 | Maximum Points Tourist Can Earn | C++ Python | O(k * n^2) | O(n) | Hard | DP | |
| 3333 | Find the Original Typed String II | C++ Python | O(n + k^2) | O(n + k) | Hard | DP | |
| 3335 | Total Characters in String After Transformations I | C++ Python | precompute: O(t + 26) runtime: O(n) |
O(t + 26) | Medium | DP, Matrix Exponentiation, Precompute | |
| 3336 | Find the Number of Subsequences With Equal GCD | C++ Python | precompute: O(max_r^2 * log(max_r)) runtime: O(n + r^2) |
O(max_r^2) | Hard | DP, Number Theory, Mobius Function, Principle of Inclusion-Exclusion, Basel Problem |
|
| 3337 | Total Characters in String After Transformations II | C++ Python | O(n + 26^3 * logt) | O(26^2) | Hard | DP, Matrix Exponentiation | |
| 3343 | Count Number of Balanced Permutations | C++ Python | O(n^2) | O(n^2) | Hard | DP, Combinatorics | |
| 3351 | Sum of Good Subsequences | C++ Python | O(n) | O(n) | Hard | Freq Table, DP | |
| 3352 | Count K-Reducible Numbers Less Than N | C++ Python | O(n^2) | O(n) | Hard | DP, Combinatorics | |
| 3359 | Find Sorted Submatrices With Maximum Element at Most K | C++ Python | O(m * n) | O(m) | Hard | π, variant of Count Submatrices With All Ones | Mono Stack, DP |
| 3363 | Find the Maximum Number of Fruits Collected | C++ Python | O(n^2) | O(1) | Hard | DP | |
| 3366 | Minimum Array Sum | C++ Python | O(nlogn) | O(n) | Medium | DP, Greedy, Case Works | |
| 3372 | Maximize the Number of Target Nodes After Connecting Trees I | C++ Python | O(nlogn + mlogm) | O(n + m) | Medium | Brute Force, BFS, DFS, Tree DP, Centroid Decomposition, Prefix Sum | |
| 3381 | Maximum Subarray Sum With Length Divisible by K | C++ Python | O(n) | O(k) | Medium | Prefix Sum, DP | |
| 3388 | Count Beautiful Splits in an Array | C++ Python | O(n^2) | O(n) | Medium | DP, Z-Function |
|
| 3389 | Minimum Operations to Make Character Frequencies Equal | C++ Python | O(26 * n) | O(26) | Hard | Freq Table, DP | |
| 3393 | Count Paths With the Given XOR Value | C++ Python | O(m * n * r) | O(n * r) | Medium | DP | |
| 3409 | Longest Subsequence With Decreasing Adjacent Difference | C++ Python | O(r^2 + n * r) | O(r^2) | Medium | DP | |
| 3414 | Maximum Score of Non-overlapping Intervals | C++ Python | O(nlogn + n * k^2) | O(n * k^2) | Hard | DP, Binary Search | |
| 3418 | Maximum Amount of Money Robot Can Earn | C++ Python | O(m * n) | O(min(m, n)) | Medium | DP | |
| 3429 | Paint House IV | C++ Python | O(n * l^4) | O(l^2) | Medium | DP | |
| 3434 | Maximum Frequency After Subarray Operation | C++ Python | O(n) | O(n) | Medium | Freq Table, DP | |
| 3441 | Minimum Cost Good Caption | C++ Python | O(26 * n) | O(26 * n) | Hard | DP, Backtracing | |
| 3444 | Minimum Increments for Target Multiples in an Array | C++ Python | O(logr * m * 2^m + n * 3^m) | O(2^m) | Hard | Bitmasks, Number Theory, DP, Submask Enumeration | |
| 3459 | Length of Longest V-Shaped Diagonal Segment | C++ Python | O(n * m) | O(n * m) | Hard | Memoization, DP | |
| 3466 | Maximum Coin Collection | C++ Python | O(n) | O(1) | Medium | π | DP |
| 3469 | Find Minimum Cost to Remove Array Elements | C++ Python | O(n^2) | O(n) | Medium | DP, Greedy | |
| 3472 | Longest Palindromic Subsequence After at Most K Operations | C++ Python | O(n^2 * k) | O(n^2 * k) | Medium | DP | |
| 3473 | Sum of K Subarrays With Length at Least M | C++ Python | O(k * n) | O(n) | Medium | Prefix Sum, DP | |
| 3489 | Zero Array Transformation IV | C++ Python | O(n^2 * r * logq) | O(r) | Medium | Binary Search, DP | |
| 3490 | Count Beautiful Numbers | C++ Python | O(logr * 2 * 10 * s) | O(logr * 2 * 10 * s) | Hard | DP | |
| 3500 | Minimum Cost to Divide Array Into Subarrays | C++ Python | O(nlogn) | O(n) | Hard | Prefix Sum, DP, Convex Hull Trick | |
| 3503 | Longest Palindrome After Substring Concatenation I | C++ Python | O(n * m) | O(n + m) | Medium | Manacher's Algorithm, DP |
|
| 3504 | Longest Palindrome After Substring Concatenation II | C++ Python | O(n * m) | O(n + m) | Hard | Manacher's Algorithm, DP |
|
| 3505 | Minimum Operations to Make Elements Within K Subarrays Equal | C++ Python | O(nlogx + k * n) | O(n) | Hard | Two Heaps, Two BSTs, Two Sorted Lists, DP | |
| 3509 | Maximum Product of Subsequences With an Alternating Sum Equal to K | C++ Python | O(n * k * l) | O(n * k * l) | Hard | DP | |
| 3524 | Find X Value of Array I | C++ Python | O(n * k) | O(k) | Medium | DP | |
| 3525 | Find X Value of Array II | C++ Python | O(n * k + q * k * logn) | O(n * k) | Hard | DP, Segment Tree | |
| 3530 | Maximum Profit from Valid Topological Order in DAG | C++ Python | O(n * 2^n) | O(2^n) | Hard | DP, Bitmasks | |
| 3533 | Concatenated Divisibility | C++ Python | O(nlogr + k * n * 2^n) | O(logr + k * 2^n) | Hard | DP, Bitmasks, Backtracing | |
| 3538 | Merge Operations for Minimum Travel Time | C++ Python | O((n-k) * k^3) | O(k^2) | Hard | Prefix Sum, DP | |
| 3539 | Find Sum of Array Product of Magical Sequences | C++ Python | O(n * k * m^2) | O(k * m^2) | Hard | DP, Combinatorics | |
| 3543 | Maximum Weighted K-Edge Path | C++ Python | O(k * e * t) | O(n * t) | Medium | DP | |
| 3544 | Subtree Inversion Sum | C++ Python | O(n) | O(n) | Hard | DFS, Tree DP | |
| 3562 | Maximum Profit from Trading Stocks with Discounts | C++ Python | O(n * b) | O(n + b) | Hard | DFS, Tree DP | |
| 3563 | Lexicographically Smallest String After Adjacent Removals | C++ Python | O(n^3) | O(n^2) | Hard | DP | |
| 3573 | Best Time to Buy and Sell Stock V | C++ Python | O(n * k) | O(k) | Medium | DP | |
| 3574 | Maximize Subarray GCD Score | C++ Python | O(nlogn * logr) | O(n + logr) | Hard | Brute Force, Number Theory, Suffix-GCD States, DP, Binary Search | |
| 3575 | Maximum Good Subtree Score | C++ Python | O(n * (2^10)^2) | O(2^10) | Hard | Bitmasks, DFS, Tree DP | |
| 3578 | Count Partitions With Max-Min Difference at Most K | C++ Python | O(n) | O(n) | Medium | Mono Deque, Two Pointers, Sliding Window, DP, Prefix Sum | |
| 3579 | Minimum Steps to Convert String with Operations | C++ Python | O(n^2) | O(26^2) | Hard | DP | |
| 3583 | Count Special Triplets | C++ Python | O(n) | O(n) | Medium | DP, Freq Table | |
| 3592 | Inverse Coin Change | C++ Python | O(n^2) | O(1) | Medium | DP | |
| 3595 | Once Twice | C++ Python | O(n) | O(1) | Medium | π | DP, Bitmasks |
| 3599 | Partition Array to Minimize XOR | C++ Python | O(n^2 * k) | O(n) | Medium | DP, Prefix Sum | |
| 3603 | Minimum Cost Path with Alternating Directions II | C++ Python | O(m * n) | O(1) | Medium | DP | |
| 3610 | Minimum Number of Primes to Sum to Target | C++ Python | O(nlog(log(min(m, n))) + m * n) | O(n) | Medium | π | Number Theory, Knapsack DP |
| 3615 | Longest Palindromic Path in Graph | C++ Python | O(n^4 * 2^n) | O(n + e) | Hard | Bitmasks, DP, Freq Table | |
| 3628 | Maximum Number of Subsequences After One Inserting | C++ Python | O(n) | O(1) | Medium | Prefix Sum, DP | |
| 3647 | Maximum Weight in Two Bags | C++ Python | O(n * w1 * w2) | O(w1 * w2) | Medium | π | DP, Bitset |
| 3651 | Minimum Cost Path with Teleportations | C++ Python | O(k * (m * n + r)) | O(m * n + r) | Hard | DP, Prefix Sum | |
| 3654 | Minimum Sum After Divisible Sum Deletions | C++ Python | O(n + k) | O(k) | Medium | DP, Prefix Sum | |
| 3661 | Maximum Walls Destroyed by Robots | C++ Python | O(nlogn + mlogm) | O(n) | Hard | Sort, DP, Two Pointers | |
| 3665 | Twisted Mirror Path Count | C++ Python | O(m * n) | O(min(m, n)) | Medium | DP | |
| 3670 | Maximum Product of Two Integers With No Common Bits | C++ Python | O(n + rlogr) | O(r) | Medium | DP, Bitmasks | |
| 3685 | Subsequence Sum After Capping Elements | C++ Python | O(nlogn + n * k) | O(k) | Medium | Sort, DP, Bitmasks | |
| 3686 | Number of Stable Subsequences | C++ Python | O(n) | O(1) | Hard | DP | |
| 3693 | Climbing Stairs II | C++ Python | O(n) | O(1) | Medium | DP | |
| 3699 | Number of ZigZag Arrays I | C++ Python | O(n * (r - l)) | O(r - l) | Hard | DP | |
| 3704 | Count No-Zero Pairs That Sum to N | C++ Python | O(10 * 2^4 * logn) | O(2^3) | Hard | DP | |
| 3717 | Minimum Operations to Make the Array Beautiful | C++ Python | O(n * rlogr) | O(r) | Medium | π | DP |
| 3725 | Count Ways to Choose Coprime Integers from Rows | C++ Python | O(n * rlogr) | O(r) | Hard | DP, Number Theory, Linear Sieve of Eratosthenes, Mobius Function, Principle of Inclusion-Exclusion |
|
| 3742 | Maximum Path Score in a Grid | C++ Python | O(m * n * k) | O(m * n * k) | Medium | DP | |
| 3743 | Maximize Cyclic Partition Score | C++ Python | O(n * k) | O(k) | Hard | variant of Best Time to Buy and Sell Stock V | DP |
| 3753 | Total Waviness of Numbers in Range II | C++ Python | O(logn * 11 * 11 * 2 * 2 * 10) | O(11 * 11 * 2 * 2) | Hard | DP, Memoization | |
| 3757 | Number of Effective Subsequences | C++ Python | O((n + r) * logr) | O(n + r) | Hard | SOS DP, Principle of Inclusion and Exclusion | |
| 3772 | Maximum Subgraph Score in a Tree | C++ Python | O(n) | O(n) | Hard | BFS, Tree DP | |
| 3791 | Number of Balanced Integers in a Range | C++ Python | O((logn)^2) | O(logn) | Hard | DP, Memoization | |
| 3801 | Minimum Cost to Merge Sorted Lists | C++ Python | O(l * nlogn + 2^n * log(n * l) * n * logl + 3^n) | O(n * l + 2^n) | Hard | DP, Sort, Heap, Binary Search, Submask Enumeration | |
| 3811 | Number of Alternating XOR Partitions | C++ Python | O(n) | O(1) | Medium | DP, Freq Table | |
| 3830 | Longest Alternating Subarray After Removing At Most One Element | C++ Python | O(n) | O(1) | Hard | DP | |
| 3836 | Maximum Score Using Exactly K Pairs | C++ Python | O(n * m * k) | O(min(n, m) * k) | Hard | DP |
| # | 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 |
| # | 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 |
| # | 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 |
| # | 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 |
| # | 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 |
| # | Title | Solution | Time | Space | Difficulty | Tag | Note |
|---|
| # | Title | Solution | Time | Space | Difficulty | Tag | Note |
|---|---|---|---|---|---|---|---|
| 3050 | Pizza Toppings Cost Analysis | MySQL | O(n^3 * logn) | O(n^3) | Medium | π | |
| 3051 | Find Candidates for Data Scientist Position | MySQL | O(nlogn) | O(n) | Easy | π | |
| 3052 | Maximize Items | MySQL | O(n) | O(n) | Hard | π | |
| 3053 | Classifying Triangles by Lengths | MySQL | O(n) | O(n) | Easy | π | |
| 3054 | Binary Tree Nodes | MySQL | O(nlogn) | O(n) | Medium | π | |
| 3055 | Top Percentile Fraud | MySQL | O(nlogn) | O(n) | Medium | π | |
| 3056 | Snaps Analysis | MySQL | O(n) | O(n) | Medium | π | |
| 3057 | Employees Project Allocation | MySQL | O(nlogn) | O(n) | Hard | π | |
| 3058 | Friends With No Mutual Friends | MySQL | O(n^2 * logn) | O(n^2) | Medium | π | |
| 3059 | Find All Unique Email Domains | MySQL | O(nlogn) | O(n) | Easy | π | |
| 3060 | User Activities within Time Bounds | MySQL | O(nlogn) | O(n) | Hard | π | |
| 3061 | Calculate Trapping Rain Water | MySQL | O(nlogn) | O(n) | Hard | π | |
| 3087 | Find Trending Hashtags | MySQL | O(nlogn) | O(n) | Medium | π | |
| 3089 | Find Bursty Behavior | MySQL | O(nlogn) | O(n) | Medium | π | Window Function |
| 3103 | Find Trending Hashtags II | MySQL | O(n * l^2 + (n * l) * log(n * l)) | O(n * l^2) | Hard | π | Recursive CTE |
| 3118 | Friday Purchase III | MySQL | O(n) | O(n) | Medium | π | |
| 3124 | Find Longest Calls | MySQL | O(nlogn) | O(n) | Medium | π | Window Function |
| 3126 | Server Utilization Time | MySQL | O(nlogn) | O(n) | Medium | Window Function | |
| 3140 | Consecutive Available Seats II | MySQL | O(nlogn) | O(n) | Medium | π | Window Function |
| 3150 | Invalid Tweets II | MySQL | O(n * l + nlogn) | O(n * l) | Easy | π | String |
| 3156 | Employee Task Duration and Concurrent Tasks | MySQL | O(nlogn) | O(n) | Hard | π | Line Sweep |
| 3166 | Calculate Parking Fees and Duration | MySQL | O(nlogn) | O(n) | Medium | π | |
| 3172 | Second Day Verification | MySQL | O(nlogn) | O(n) | Easy | π | |
| 3182 | Find Top Scoring Students | MySQL | O(nlogn) | O(n) | Medium | π | |
| 3188 | Find Top Scoring Students II | MySQL | O(nlogn) | O(n) | Hard | π | |
| 3198 | Find Cities in Each State | MySQL | O(nlogn) | O(n) | Easy | π | |
| 3204 | Bitwise User Permissions Analysis | MySQL | O(n) | O(n) | Medium | π | |
| 3214 | Year on Year Growth Rate | MySQL | O(nlogn) | O(n) | Hard | π | Window Function |
| 3220 | Odd and Even Transactions | MySQL | O(nlogn) | O(n) | Medium | ||
| 3230 | Customer Purchasing Behavior Analysis | MySQL | O(nlogn) | O(n) | Medium | π | Window Function |
| 3236 | CEO Subordinate Hierarchy | MySQL | O(nlogn) | O(n) | Hard | π | Recursive CTE, BFS |
| 3246 | Premier League Table Ranking | MySQL | O(nlogn) | O(n) | Easy | π | Window Function |
| 3252 | Premier League Table Ranking II | MySQL | O(nlogn) | O(n) | Medium | π | Window Function |
| 3262 | Find Overlapping Shifts | MySQL | O(nlogn) | O(n) | Medium | π | Line Sweep |
| 3268 | Find Overlapping Shifts II | MySQL | O(n^2) | O(n^2) | Hard | π | Line Sweep, Window Function, Combinatorics |
| 3278 | Find Candidates for Data Scientist Position II | MySQL | O(p * s * n + p * nlogn + plogp) | O(p * s * n) | Medium | π | Window Function |
| 3293 | Calculate Product Final Price | MySQL | O(nlogn) | O(n) | Medium | π | |
| 3308 | Find Top Performing Driver | MySQL | O(tlogt) | O(t) | Medium | π | Window Function |
| 3322 | Premier League Table Ranking III | MySQL | O(nlogn) | O(n) | Medium | π | Window Function |
| 3328 | Find Cities in Each State II | MySQL | O(nlogn) | O(n) | Medium | π | |
| 3338 | Second Highest Salary II | MySQL | O(nlogn) | O(n) | Medium | π | Window Function |
| 3358 | Books with NULL Ratings | MySQL | O(nlogn) | O(n) | Easy | π | |
| 3368 | First Letter Capitalization | MySQL | O(n * l^2 + (n * l) * log(n * l)) | O(n * l^2) | Hard | π | Recursive CTE |
| 3374 | First Letter Capitalization II | MySQL | O(n * l^2 + (n * l) * log(n * l)) | O(n * l^2) | Hard | π | Recursive CTE |
| 3384 | Team Dominance by Pass Success | MySQL | O(plogp + t) | O(p + t) | Hard | π | |
| 3390 | Longest Team Pass Streak | MySQL | O(plogp + t) | O(p + t) | Hard | π | Recursive CTE, Window Function |
| 3401 | Find Circular Gift Exchange Chains | MySQL | O(n^2) | O(n^2) | Hard | π | Recursive CTE, Window Function |
| 3415 | Find Products with Three Consecutive Digits | MySQL | O(nlogn) | O(n) | Easy | π | Regular Expression |
| 3421 | Find Students Who Improved | MySQL | O(nlogn) | O(n) | Medium | π | Window Function |
| 3436 | Find Valid Emails | MySQL | O(n) | O(n) | Easy | Regular Expression | |
| 3451 | Find Invalid IP Addresses | MySQL | O(nlogn) | O(n) | Hard | Regular Expression | |
| 3465 | Find Products with Valid Serial Numbers | MySQL | O(nlogn) | O(n) | Easy | Regular Expression | |
| 3475 | DNA Pattern Recognition | MySQL | O(nlogn) | O(n) | Medium | Regular Expression | |
| 3482 | Analyze Organization Hierarchy | MySQL | O(n^2) | O(n^2) | Hard | Recursive CTE, BFS | |
| 3497 | Analyze Subscription Conversion | MySQL | O(nlogn) | O(n) | Medium | ||
| 3521 | Find Product Recommendation Pairs | MySQL | O(n^2 * logn) | O(n^2) | Medium | ||
| 3554 | Find Category Recommendation Pairs | MySQL | O(n^2 * logn) | O(n^2) | Hard | ||
| 3564 | Seasonal Sales Analysis | MySQL | O(nlogn) | O(n) | Medium | Window Function | |
| 3570 | Find Books with No Available Copies | MySQL | O(nlogn) | O(n) | Easy | ||
| 3580 | Find Consistently Improving Employees | MySQL | O(nlogn) | O(n) | Medium | Window Function | |
| 3586 | Find COVID Recovery Patients | MySQL | O(n^2) | O(n^2) | Medium | ||
| 3601 | Find Drivers with Improved Fuel Efficiency | MySQL | O(nlogn) | O(n) | Medium | ||
| 3611 | Find Overbooked Employees | MySQL | O(m + nlogn) | O(m + n) | Medium | ||
| 3617 | Find Students with Study Spiral Pattern | MySQL | O(nlogn) | O(n) | Hard | Window Function | |
| 3626 | Find Stores with Inventory Imbalance | MySQL | O(n^2 * logn) | O(n^2) | Medium | ||
| 3642 | Find Books with Polarized Opinions | MySQL | O(r + nlogn) | O(r + n) | Easy | ||
| 3657 | Find Loyal Customers | MySQL | O(nlogn) | O(n) | Medium | ||
| 3673 | Find Zombie Sessions | MySQL | O(nlogn) | O(n) | Hard | ||
| 3705 | Find Golden Hour Customers | MySQL | O(nlogn) | O(n) | Medium | ||
| 3716 | Find Churn Risk Customers | MySQL | O(nlogn) | O(n) | Medium | Window Function | |
| 3764 | Most Common Course Pairs | MySQL | O(nlogn) | O(n) | Hard | Window Function | |
| 3793 | Find Users with High Token Usage | MySQL | O(nlogn) | O(n) | Easy | ||
| 3808 | Find Emotionally Consistent Users | MySQL | O(nlogn) | O(n) | Medium | Window Function | |
| 3832 | Find Users with Persistent Behavior Patterns | MySQL | O(nlogn) | O(n) | Hard | Window Function |
| # | Title | Solution | Time | Space | Difficulty | Tag | Note |
|---|