# [LeetCode](https://leetcode.com/problemset/all/)

&nbsp;
[](./LICENSE.md)&nbsp;
&nbsp;
&nbsp;
[](https://saythanks.io/to/kamyu104)&nbsp;


* R.I.P. to my old Leetcode repository, where there were `5.7k+` stars and `2.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](https://github.com/kamyu104/LintCode), [GoogleKickStart](https://github.com/kamyu104/GoogleKickStart-2022), [GoogleCodeJamIO](https://github.com/kamyu104/GoogleCodeJamIO-2022) repositories.
* For more challenging problem solutions, you can also see my [GoogleCodeJam](https://github.com/kamyu104/GoogleCodeJam-Farewell-Rounds), [MetaHackerCup](https://github.com/kamyu104/MetaHackerCup-2025) repositories.
* Hope you enjoy the journey of learning data structures and algorithms.
* Notes: "🔒" means your subscription of [LeetCode premium membership](https://leetcode.com/subscribe/) is required for reading the question.

## Solutions
- [0001 - 1000](./0001-1000.md)
- [1001 - 2000](./1001-2000.md)
- [2001 - 3000](./2001-3000.md)
- [3001 - Latest](./README.md)

## Algorithms

* [Bit Manipulation](https://github.com/kamyu104/LeetCode-Solutions#bit-manipulation)
* [Array](https://github.com/kamyu104/LeetCode-Solutions#array)
* [String](https://github.com/kamyu104/LeetCode-Solutions#string)
* [Linked List](https://github.com/kamyu104/LeetCode-Solutions#linked-list)
* [Stack](https://github.com/kamyu104/LeetCode-Solutions#stack)
* [Queue](https://github.com/kamyu104/LeetCode-Solutions#queue)
* [Binary Heap](https://github.com/kamyu104/LeetCode-Solutions#binary-heap)
* [Tree](https://github.com/kamyu104/LeetCode-Solutions#tree)
* [Hash Table](https://github.com/kamyu104/LeetCode-Solutions#hash-table)
* [Math](https://github.com/kamyu104/LeetCode-Solutions#math)
* [Sort](https://github.com/kamyu104/LeetCode-Solutions#sort)
* [Two Pointers](https://github.com/kamyu104/LeetCode-Solutions#two-pointers)
* [Recursion](https://github.com/kamyu104/LeetCode-Solutions#recursion)
* [Binary Search](https://github.com/kamyu104/LeetCode-Solutions#binary-search)
* [Binary Search Tree](https://github.com/kamyu104/LeetCode-Solutions#binary-search-tree)
* [Breadth-First Search](https://github.com/kamyu104/LeetCode-Solutions#breadth-first-search)
* [Depth-First Search](https://github.com/kamyu104/LeetCode-Solutions#depth-first-search)
* [Backtracking](https://github.com/kamyu104/LeetCode-Solutions#backtracking)
* [Dynamic Programming](https://github.com/kamyu104/LeetCode-Solutions#dynamic-programming)
* [Greedy](https://github.com/kamyu104/LeetCode-Solutions#greedy)
* [Graph](https://github.com/kamyu104/LeetCode-Solutions#graph)
* [Geometry](https://github.com/kamyu104/LeetCode-Solutions#geometry)
* [Simulation](https://github.com/kamyu104/LeetCode-Solutions#simulation)
* [Constructive Algorithms](https://github.com/kamyu104/LeetCode-Solutions#constructive-algorithms)
* [Design](https://github.com/kamyu104/LeetCode-Solutions#design)

## JavaScript

* [JS](https://github.com/kamyu104/LeetCode-Solutions#js)

## Database

* [SQL](https://github.com/kamyu104/LeetCode-Solutions#sql)


## Pandas

* [PD](https://github.com/kamyu104/LeetCode-Solutions#pd)

## Reference

* [Links](./REFERENCE.md)

## Bit Manipulation
|  #  | Title           |  Solution       |  Time           | Space           | Difficulty    | Tag          | Note| 
|-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------|-----|
3064 | [Guess the Number Using Bitwise Questions I](https://leetcode.com/problems/guess-the-number-using-bitwise-questions-i/) | [C++](./C++/guess-the-number-using-bitwise-questions-i.cpp) [Python](./Python/guess-the-number-using-bitwise-questions-i.py) | _O(logn)_ | _O(1)_ | Medium |🔒| Bit Manipulation
3094 | [Guess the Number Using Bitwise Questions II](https://leetcode.com/problems/guess-the-number-using-bitwise-questions-ii/) | [C++](./C++/guess-the-number-using-bitwise-questions-ii.cpp) [Python](./Python/guess-the-number-using-bitwise-questions-ii.py) | _O(logr)_ | _O(1)_ | Medium |🔒| Bit Manipulation
3125 | [Maximum Number That Makes Result of Bitwise AND Zero](https://leetcode.com/problems/maximum-number-that-makes-result-of-bitwise-and-zero/) | [C++](./C++/maximum-number-that-makes-result-of-bitwise-and-zero.cpp) [Python](./Python/maximum-number-that-makes-result-of-bitwise-and-zero.py) | _O(1)_ | _O(1)_ | Medium |🔒| Bit Manipulation
3133 | [Minimum Array End](https://leetcode.com/problems/minimum-array-end/) | [C++](./C++/minimum-array-end.cpp) [Python](./Python/minimum-array-end.py) | _O(logn)_ | _O(1)_ | Medium | | Bit Manipulation
3199 | [Count Triplets with Even XOR Set Bits I](https://leetcode.com/problems/count-triplets-with-even-xor-set-bits-i/) | [C++](./C++/count-triplets-with-even-xor-set-bits-i.cpp) [Python](./Python/count-triplets-with-even-xor-set-bits-i.py) | _O(nlogr)_ | _O(1)_ | Easy | 🔒 | Brute Force, Bit Manipulation, Parity
3215 | [Count Triplets with Even XOR Set Bits II](https://leetcode.com/problems/count-triplets-with-even-xor-set-bits-ii/) | [C++](./C++/count-triplets-with-even-xor-set-bits-ii.cpp) [Python](./Python/count-triplets-with-even-xor-set-bits-ii.py) | _O(nlogr)_ | _O(1)_ | Medium | 🔒 | Bit Manipulation, Parity
3226 | [Number of Bit Changes to Make Two Integers Equal](https://leetcode.com/problems/number-of-bit-changes-to-make-two-integers-equal/) | [C++](./C++/number-of-bit-changes-to-make-two-integers-equal.cpp) [Python](./Python/number-of-bit-changes-to-make-two-integers-equal.py) | _O(logn)_ | _O(1)_ | Easy | | Bit Manipulation
3289 | [The Two Sneaky Numbers of Digitville](https://leetcode.com/problems/the-two-sneaky-numbers-of-digitville/) | [C++](./C++/the-two-sneaky-numbers-of-digitville.cpp) [Python](./Python/the-two-sneaky-numbers-of-digitville.py) | _O(n)_ | _O(1)_ | Easy | | Bit Manipulation
3304 | [Find the K-th Character in String Game I](https://leetcode.com/problems/find-the-k-th-character-in-string-game-i/) | [C++](./C++/find-the-k-th-character-in-string-game-i.cpp) [Python](./Python/find-the-k-th-character-in-string-game-i.py) | _O(n)_ | _O(1)_ | Easy | | Bitmasks
3307| [Find the K-th Character in String Game II](https://leetcode.com/problems/find-the-k-th-character-in-string-game-ii/) | [C++](./C++/find-the-k-th-character-in-string-game-ii.cpp) [Python](./Python/find-the-k-th-character-in-string-game-ii.py) | _O(1)_ | _O(1)_ | Hard | | Bitmasks
3314 | [Construct the Minimum Bitwise Array I](https://leetcode.com/problems/construct-the-minimum-bitwise-array-i/) | [C++](./C++/construct-the-minimum-bitwise-array-i.cpp) [Python](./Python/construct-the-minimum-bitwise-array-i.py) | _O(n)_ | _O(1)_ | Easy | | Bit Manipulation
3315 | [Construct the Minimum Bitwise Array II](https://leetcode.com/problems/construct-the-minimum-bitwise-array-ii/) | [C++](./C++/construct-the-minimum-bitwise-array-ii.cpp) [Python](./Python/construct-the-minimum-bitwise-array-ii.py) | _O(n)_ | _O(1)_ | Medium | | Bit Manipulation
3344 | [Maximum Sized Array](https://leetcode.com/problems/maximum-sized-array/) | [C++](./C++/maximum-sized-array.cpp) [Python](./Python/maximum-sized-array.py) | 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](https://leetcode.com/problems/smallest-number-with-all-set-bits/) | [C++](./C++/smallest-number-with-all-set-bits.cpp) [Python](./Python/smallest-number-with-all-set-bits.py) | _O(1)_ | _O(1)_ | Easy | | Bit Manipulation
3566 | [Partition Array into Two Equal Product Subsets](https://leetcode.com/problems/partition-array-into-two-equal-product-subsets/) | [C++](./C++/partition-array-into-two-equal-product-subsets.cpp) [Python](./Python/partition-array-into-two-equal-product-subsets.py) | _O(n * 2^n)_ | _O(1)_ | Medium | | Bitmasks
3632 | [Subarrays with XOR at Least K](https://leetcode.com/problems/subarrays-with-xor-at-least-k/) | [C++](./C++/subarrays-with-xor-at-least-k.cpp) [Python](./Python/subarrays-with-xor-at-least-k.py) | _O(nlogr)_ | _O(t)_ | Hard | 🔒 | Bitmasks, Prefix Sum, Trie
3646 | [Next Special Palindrome Number](https://leetcode.com/problems/next-special-palindrome-number/) | [C++](./C++/next-special-palindrome-number.cpp) [Python](./Python/next-special-palindrome-number.py) | 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](https://leetcode.com/problems/longest-subsequence-with-non-zero-bitwise-xor/) | [C++](./C++/longest-subsequence-with-non-zero-bitwise-xor.cpp) [Python](./Python/longest-subsequence-with-non-zero-bitwise-xor.py) | _O(n)_ | _O(1)_ | Medium | | Bitmasks
3750 | [Minimum Number of Flips to Reverse Binary String](https://leetcode.com/problems/minimum-number-of-flips-to-reverse-binary-string/) | [C++](./C++/minimum-number-of-flips-to-reverse-binary-string.cpp) [Python](./Python/minimum-number-of-flips-to-reverse-binary-string.py) | _O(logn)_ | _O(1)_ | Easy | | Bitmasks
3766 | [Minimum Operations to Make Binary Palindrome](https://leetcode.com/problems/minimum-operations-to-make-binary-palindrome/) | [C++](./C++/minimum-operations-to-make-binary-palindrome.cpp) [Python](./Python/minimum-operations-to-make-binary-palindrome.py) | precompute: _O(sqrt(r) * logr)_runtime: _O(r)_ | _O(r)_ | Medium | | Precompute, Bitmasks, Two Pointers
3769 | [Sort Integers by Binary Reflection](https://leetcode.com/problems/sort-integers-by-binary-reflection/) | [C++](./C++/sort-integers-by-binary-reflection.cpp) [Python](./Python/sort-integers-by-binary-reflection.py) | _O(nlogr + nlogn)_ | _O(n)_ | Easy | | Sort, Bitmasks
3782 | [Last Remaining Integer After Alternating Deletion Operations](https://leetcode.com/problems/last-remaining-integer-after-alternating-deletion-operations/) | [C++](./C++/last-remaining-integer-after-alternating-deletion-operations.cpp) [Python](./Python/last-remaining-integer-after-alternating-deletion-operations.py) | _O(1)_ | _O(1)_ | Hard | | Bitmasks, Simulation
3827 | [Count Monobit Integers](https://leetcode.com/problems/count-monobit-integers/) | [C++](./C++/count-monobit-integers.cpp) [Python](./Python/count-monobit-integers.py) | _O(logn)_ | _O(1)_ | Easy | | Bitmasks
3950 | [Exactly One Consecutive Set Bits Pair](https://leetcode.com/problems/exactly-one-consecutive-set-bits-pair/) | [C++](./C++/exactly-one-consecutive-set-bits-pair.cpp) [Python](./Python/exactly-one-consecutive-set-bits-pair.py) | _O(1)_ | _O(1)_ | Easy | | Bit Manipulation
4005 | [Minimum Operations to Make Array Equal III](https://leetcode.com/problems/minimum-operations-to-make-array-equal-iii/) | [C++](./C++/minimum-operations-to-make-array-equal-iii.cpp) [Python](./Python/minimum-operations-to-make-array-equal-iii.py) | _O(nlogr)_ | _O(n)_ | Hard | 🔒 | Freq Table, Bit Manipulation



    **[⬆️ Back to Top](#algorithms)**



## Array
|  #  | Title           |  Solution       |  Time           | Space           | Difficulty    | Tag          | Note| 
|-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------|-----|
3009 | [Maximum Number of Intersections on the Chart](https://leetcode.com/problems/maximum-number-of-intersections-on-the-chart/) | [C++](./C++/maximum-number-of-intersections-on-the-chart.cpp) [Python](./Python/maximum-number-of-intersections-on-the-chart.py) | _O(nlogn)_ | _O(n)_ | Hard | 🔒 | Sort, Line Sweep, Coordinate Compression
3010 | [Divide an Array Into Subarrays With Minimum Cost I](https://leetcode.com/problems/divide-an-array-into-subarrays-with-minimum-cost-i/) | [C++](./C++/divide-an-array-into-subarrays-with-minimum-cost-i.cpp) [Python](./Python/divide-an-array-into-subarrays-with-minimum-cost-i.py) | _O(n)_ | _O(1)_ | Easy | | Array, Quick Select
3015 | [Count the Number of Houses at a Certain Distance I](https://leetcode.com/problems/count-the-number-of-houses-at-a-certain-distance-i/) | [C++](./C++/count-the-number-of-houses-at-a-certain-distance-i.cpp) [Python](./Python/count-the-number-of-houses-at-a-certain-distance-i.py) | _O(n)_   | _O(n)_        | Medium         | | Math, Prefix Sum, Difference Array
3017 | [Count the Number of Houses at a Certain Distance II](https://leetcode.com/problems/count-the-number-of-houses-at-a-certain-distance-ii/) | [C++](./C++/count-the-number-of-houses-at-a-certain-distance-ii.cpp) [Python](./Python/count-the-number-of-houses-at-a-certain-distance-ii.py) | _O(n)_   | _O(1)_        | Hard         | | Math, Prefix Sum, Difference Array
3026 | [Maximum Good Subarray Sum](https://leetcode.com/problems/maximum-good-subarray-sum/) | [C++](./C++/maximum-good-subarray-sum.cpp) [Python](./Python/maximum-good-subarray-sum.py) | _O(n)_ | _O(n)_ | Medium | | Prefix Sum
3028 | [Ant on the Boundary](https://leetcode.com/problems/ant-on-the-boundary/) | [C++](./C++/ant-on-the-boundary.cpp) [Python](./Python/ant-on-the-boundary.py) | _O(n)_ | _O(1)_ | Easy | | Prefix Sum
3030 | [Find the Grid of Region Average](https://leetcode.com/problems/find-the-grid-of-region-average/) | [C++](./C++/find-the-grid-of-region-average.cpp) [Python](./Python/find-the-grid-of-region-average.py) | _O(m * n)_ | _O(m * n)_ | Medium | | Array
3033 | [Modify the Matrix](https://leetcode.com/problems/modify-the-matrix/) | [C++](./C++/modify-the-matrix.cpp) [Python](./Python/modify-the-matrix.py) | _O(m * n)_ | _O(1)_ | Easy | | Array
3038 | [Maximum Number of Operations With the Same Score I](https://leetcode.com/problems/maximum-number-of-operations-with-the-same-score-i/) | [C++](./C++/maximum-number-of-operations-with-the-same-score-i.cpp) [Python](./Python/maximum-number-of-operations-with-the-same-score-i.py) | _O(n)_ | _O(1)_ | Easy | | Array
3065 | [Minimum Operations to Exceed Threshold Value I](https://leetcode.com/problems/minimum-operations-to-exceed-threshold-value-i/) | [C++](./C++/minimum-operations-to-exceed-threshold-value-i.cpp) [Python](./Python/minimum-operations-to-exceed-threshold-value-i.py) | _O(n)_ | _O(1)_ | Easy | | Array
3069 | [Distribute Elements Into Two Arrays I](https://leetcode.com/problems/distribute-elements-into-two-arrays-i/) | [C++](./C++/distribute-elements-into-two-arrays-i.cpp) [Python](./Python/distribute-elements-into-two-arrays-i.py) | _O(n)_ | _O(n)_ | Easy | | Array
3070 | [Count Submatrices with Top-Left Element and Sum Less Than k](https://leetcode.com/problems/count-submatrices-with-top-left-element-and-sum-less-than-k/) | [C++](./C++/count-submatrices-with-top-left-element-and-sum-less-than-k.cpp) [Python](./Python/count-submatrices-with-top-left-element-and-sum-less-than-k.py) | _O(n * m)_ | _O(1)_ | Medium | | Array, Prefix Sum
3071 | [Minimum Operations to Write the Letter Y on a Grid](https://leetcode.com/problems/minimum-operations-to-write-the-letter-y-on-a-grid/) | [C++](./C++/minimum-operations-to-write-the-letter-y-on-a-grid.cpp) [Python](./Python/minimum-operations-to-write-the-letter-y-on-a-grid.py) | _O(n^2)_ | _O(1)_ | Medium | | Array
3079 | [Find the Sum of Encrypted Integers](https://leetcode.com/problems/find-the-sum-of-encrypted-integers/) | [C++](./C++/find-the-sum-of-encrypted-integers.cpp) [Python](./Python/find-the-sum-of-encrypted-integers.py) | _O(nlogr)_ | _O(1)_ | Easy | | Array
3096 | [Minimum Levels to Gain More Points](https://leetcode.com/problems/minimum-levels-to-gain-more-points/) | [C++](./C++/minimum-levels-to-gain-more-points.cpp) [Python](./Python/minimum-levels-to-gain-more-points.py) | _O(n)_ | _O(n)_ | Medium | | Prefix Sum
3105 | [Longest Strictly Increasing or Strictly Decreasing Subarray](https://leetcode.com/problems/longest-strictly-increasing-or-strictly-decreasing-subarray/) | [C++](./C++/longest-strictly-increasing-or-strictly-decreasing-subarray.cpp) [Python](./Python/longest-strictly-increasing-or-strictly-decreasing-subarray.py) | _O(n)_ | _O(1)_ | Easy | | Array
3127 | [Make a Square with the Same Color](https://leetcode.com/problems/make-a-square-with-the-same-color/) | [C++](./C++/make-a-square-with-the-same-color.cpp) [Python](./Python/make-a-square-with-the-same-color.py) | _O((n - w + 1)^2 * w^2)_ | _O(1)_ | Easy | | Array
3131 | [Find the Integer Added to Array I](https://leetcode.com/problems/find-the-integer-added-to-array-i/) | [C++](./C++/find-the-integer-added-to-array-i.cpp) [Python](./Python/find-the-integer-added-to-array-i.py) | _O(n)_ | _O(1)_ | Easy | | Array
3142 | [Check if Grid Satisfies Conditions](https://leetcode.com/problems/check-if-grid-satisfies-conditions/) | [C++](./C++/check-if-grid-satisfies-conditions.cpp) [Python](./Python/check-if-grid-satisfies-conditions.py) | _O(m * n)_ | _O(1)_ | Easy | | Array
3147 | [Taking Maximum Energy From the Mystic Dungeon](https://leetcode.com/problems/taking-maximum-energy-from-the-mystic-dungeon/) | [C++](./C++/taking-maximum-energy-from-the-mystic-dungeon.cpp) [Python](./Python/taking-maximum-energy-from-the-mystic-dungeon.py) | _O(n)_ | _O(1)_ | Medium | | Array
3151 | [Special Array I](https://leetcode.com/problems/special-array-i/) | [C++](./C++/special-array-i.cpp) [Python](./Python/special-array-i.py) | _O(n)_ | _O(1)_ | Easy | | Array
3152 | [Special Array II](https://leetcode.com/problems/special-array-ii/) | [C++](./C++/special-array-ii.cpp) [Python](./Python/special-array-ii.py) | _O(n + q)_ | _O(n)_ | Medium | | Prefix Sum
3153 | [Sum of Digit Differences of All Pairs](https://leetcode.com/problems/sum-of-digit-differences-of-all-pairs/) | [C++](./C++/sum-of-digit-differences-of-all-pairs.cpp) [Python](./Python/sum-of-digit-differences-of-all-pairs.py) | _O(nlogr)_ | _O(10 * logr)_ | Medium | | Prefix Sum
3159 | [Find Occurrences of an Element in an Array](https://leetcode.com/problems/find-occurrences-of-an-element-in-an-array/) | [C++](./C++/find-occurrences-of-an-element-in-an-array.cpp) [Python](./Python/find-occurrences-of-an-element-in-an-array.py) | _O(n + q)_ | _O(n)_ | Medium | | Array
3173 | [Bitwise OR of Adjacent Elements](https://leetcode.com/problems/bitwise-or-of-adjacent-elements/) | [C++](./C++/bitwise-or-of-adjacent-elements.cpp) [Python](./Python/bitwise-or-of-adjacent-elements.py) | _O(n)_ | _O(1)_ | Easy | 🔒 | Array
3187 | [Peaks in Array](https://leetcode.com/problems/peaks-in-array/) | [C++](./C++/peaks-in-array.cpp) [Python](./Python/peaks-in-array.py) | _O(n + qlogn)_ | _O(n)_ | Hard | | BIT, Fenwick Tree
3195 | [Find the Minimum Area to Cover All Ones I](https://leetcode.com/problems/find-the-minimum-area-to-cover-all-ones-i/) | [C++](./C++/find-the-minimum-area-to-cover-all-ones-i.cpp) [Python](./Python/find-the-minimum-area-to-cover-all-ones-i.py) | _O(n * m)_ | _O(1)_ | Medium | | Array
3224 | [Minimum Array Changes to Make Differences Equal](https://leetcode.com/problems/minimum-array-changes-to-make-differences-equal/) | [C++](./C++/minimum-array-changes-to-make-differences-equal.cpp) [Python](./Python/minimum-array-changes-to-make-differences-equal.py) | _O(n + k)_   | _O(k)_        | Medium         | | Prefix Sum, Difference Array
3279 | [Maximum Total Area Occupied by Pistons](https://leetcode.com/problems/maximum-total-area-occupied-by-pistons/) | [C++](./C++/maximum-total-area-occupied-by-pistons.cpp) [Python](./Python/maximum-total-area-occupied-by-pistons.py) | _O(h)_ | _O(h)_ | Hard | 🔒 | Line Sweep, Difference Array
3285 | [Find Indices of Stable Mountains](https://leetcode.com/problems/find-indices-of-stable-mountains/) | [C++](./C++/find-indices-of-stable-mountains.cpp) [Python](./Python/find-indices-of-stable-mountains.py) | _O(n)_ | _O(1)_ | Easy | | Array
3300 | [Minimum Element After Replacement With Digit Sum](https://leetcode.com/problems/minimum-element-after-replacement-with-digit-sum/) | [C++](./C++/minimum-element-after-replacement-with-digit-sum.cpp) [Python](./Python/minimum-element-after-replacement-with-digit-sum.py) | _O(nlogr)_ | _O(1)_ | Easy | | Array
3330 | [Find the Original Typed String I](https://leetcode.com/problems/find-the-original-typed-string-i/) | [C++](./C++/find-the-original-typed-string-i.cpp) [Python](./Python/find-the-original-typed-string-i.py) | _O(n)_ | _O(1)_ | Easy | | Array
3334 | [Find the Maximum Factor Score of Array](https://leetcode.com/problems/find-the-maximum-factor-score-of-array/) | [C++](./C++/find-the-maximum-factor-score-of-array.cpp) [Python](./Python/find-the-maximum-factor-score-of-array.py) | _O(nlogr)_ | _O(n)_ | Medium | | Prefix Sum
3349 | [Adjacent Increasing Subarrays Detection I](https://leetcode.com/problems/adjacent-increasing-subarrays-detection-i/) | [C++](./C++/adjacent-increasing-subarrays-detection-i.cpp) [Python](./Python/adjacent-increasing-subarrays-detection-i.py) | _O(n)_ | _O(1)_ | Easy | | Array
3350 | [Adjacent Increasing Subarrays Detection II](https://leetcode.com/problems/adjacent-increasing-subarrays-detection-ii/) | [C++](./C++/adjacent-increasing-subarrays-detection-ii.cpp) [Python](./Python/adjacent-increasing-subarrays-detection-ii.py) | _O(n)_ | _O(1)_ | Medium | | Array
3353 | [Minimum Total Operations](https://leetcode.com/problems/minimum-total-operations/) | [C++](./C++/minimum-total-operations.cpp) [Python](./Python/minimum-total-operations.py) | _O(n)_   | _O(1)_        | Easy         | 🔒 | Array
3354 | [Make Array Elements Equal to Zero](https://leetcode.com/problems/make-array-elements-equal-to-zero/) | [C++](./C++/make-array-elements-equal-to-zero.cpp) [Python](./Python/make-array-elements-equal-to-zero.py) | _O(n)_   | _O(n)_        | Easy         | [CodeChef Starters 146 - Bouncing Ball](https://www.codechef.com/problems/BOUNCE_BALL) | Prefix Sum
3355 | [Zero Array Transformation I](https://leetcode.com/problems/zero-array-transformation-i/) | [C++](./C++/zero-array-transformation-i.cpp) [Python](./Python/zero-array-transformation-i.py) | _O(n + q)_   | _O(n)_        | Medium         | | Line Sweep
3361 | [Shift Distance Between Two Strings](https://leetcode.com/problems/shift-distance-between-two-strings/) | [C++](./C++/shift-distance-between-two-strings.cpp) [Python](./Python/shift-distance-between-two-strings.py) | _O(n + 26)_   | _O(26)_        | Medium         | | Prefix Sum
3379 | [Transformed Array](https://leetcode.com/problems/transformed-array/) | [C++](./C++/transformed-array.cpp) [Python](./Python/transformed-array.py) | _O(n)_   | _O(1)_        | Easy         | | Array
3380 | [Maximum Area Rectangle With Point Constraints I](https://leetcode.com/problems/maximum-area-rectangle-with-point-constraints-i/) | [C++](./C++/maximum-area-rectangle-with-point-constraints-i.cpp) [Python](./Python/maximum-area-rectangle-with-point-constraints-i.py) | _O(nlogn)_   | _O(n)_        | Medium         | | Sort, Brute Force, BIT, Fenwick Tree, Hash Table
3382 | [Maximum Area Rectangle With Point Constraints II](https://leetcode.com/problems/maximum-area-rectangle-with-point-constraints-ii/) | [C++](./C++/maximum-area-rectangle-with-point-constraints-ii.cpp) [Python](./Python/maximum-area-rectangle-with-point-constraints-ii.py) | _O(nlogn)_   | _O(n)_        | Hard         | | Sort, BIT, Fenwick Tree, Hash Table
3386 | [Button with Longest Push Time](https://leetcode.com/problems/button-with-longest-push-time/) | [C++](./C++/button-with-longest-push-time.cpp) [Python](./Python/button-with-longest-push-time.py) | _O(n)_   | _O(1)_        | Easy         | | Array
3392 | [Count Subarrays of Length Three With a Condition](https://leetcode.com/problems/count-subarrays-of-length-three-with-a-condition/) | [C++](./C++/count-subarrays-of-length-three-with-a-condition.cpp) [Python](./Python/count-subarrays-of-length-three-with-a-condition.py) | _O(n)_   | _O(1)_        | Easy         | | Array
3400 | [Maximum Number of Matching Indices After Right Shifts](https://leetcode.com/problems/maximum-number-of-matching-indices-after-right-shifts/) | [C++](./C++/maximum-number-of-matching-indices-after-right-shifts.cpp) [Python](./Python/maximum-number-of-matching-indices-after-right-shifts.py) | _O(n^2)_ | _O(1)_ | Medium | 🔒 | Brute Force
3417 | [Zigzag Grid Traversal With Skip](https://leetcode.com/problems/zigzag-grid-traversal-with-skip/) | [C++](./C++/zigzag-grid-traversal-with-skip.cpp) [Python](./Python/zigzag-grid-traversal-with-skip.py) | _O(n * m)_ | _O(1)_ | Easy | | Array
3423 | [Maximum Difference Between Adjacent Elements in a Circular Array](https://leetcode.com/problems/zmaximum-difference-between-adjacent-elements-in-a-circular-array/) | [C++](./C++/maximum-difference-between-adjacent-elements-in-a-circular-array.cpp) [Python](./Python/maximum-difference-between-adjacent-elements-in-a-circular-array.py) | _O(n)_ | _O(1)_ | Easy | | Array
3427 | [Sum of Variable Length Subarrays](https://leetcode.com/problems/sum-of-variable-length-subarrays/) | [C++](./C++/sum-of-variable-length-subarrays.cpp) [Python](./Python/sum-of-variable-length-subarrays.py) | _O(n)_   | _O(n)_        | Easy         | | Difference Array
3432 | [Count Partitions with Even Sum Difference](https://leetcode.com/problems/count-partitions-with-even-sum-difference/) | [C++](./C++/count-partitions-with-even-sum-difference.cpp) [Python](./Python/count-partitions-with-even-sum-difference.py) | _O(n)_   | _O(1)_        | Easy         | | Prefix Sum
3440 | [Reschedule Meetings for Maximum Free Time II](https://leetcode.com/problems/reschedule-meetings-for-maximum-free-time-ii/) | [C++](./C++/reschedule-meetings-for-maximum-free-time-ii.cpp) [Python](./Python/reschedule-meetings-for-maximum-free-time-ii.py) | _O(n)_ | _O(1)_ | Medium | | Array
3446 | [Sort Matrix by Diagonals](https://leetcode.com/problems/sort-matrix-by-diagonals/) | [C++](./C++/sort-matrix-by-diagonals.cpp) [Python](./Python/sort-matrix-by-diagonals.py) | _O(n^2 * logn)_ | _O(n^2)_ | Medium | | Array, Sort
3452 | [Sum of Good Numbers](https://leetcode.com/problems/sum-of-good-numbers/) | [C++](./C++/sum-of-good-numbers.cpp) [Python](./Python/sum-of-good-numbers.py) | _O(n)_ | _O(1)_ | Easy | | Array
3467 | [Transform Array by Parity](https://leetcode.com/problems/transform-array-by-parity/) | [C++](./C++/transform-array-by-parity.cpp) [Python](./Python/transform-array-by-parity.py) | _O(n)_ | _O(1)_ | Easy | | Array
3502 | [Minimum Cost to Reach Every Position](https://leetcode.com/problems/minimum-cost-to-reach-every-position/) | [C++](./C++/minimum-cost-to-reach-every-position.cpp) [Python](./Python/minimum-cost-to-reach-every-position.py) | _O(n)_ | _O(1)_ | Easy | | Prefix Sum
3514 | [Number of Unique XOR Triplets II](https://leetcode.com/problems/number-of-unique-xor-triplets-ii/) | [C++](./C++/number-of-unique-xor-triplets-ii.cpp) [Python](./Python/number-of-unique-xor-triplets-ii.py) | _O(nlogn)_ | _O(n)_ | Medium | | `Fast Walsh–Hadamard Transform`, FWHT, `Fast Subset Transform`, FST, Hash Table
3531 | [Count Covered Buildings](https://leetcode.com/problems/count-covered-buildings/) | [C++](./C++/count-covered-buildings.cpp) [Python](./Python/count-covered-buildings.py) | _O(n)_ | _O(n)_ | Medium | | Array
3537 | [Fill a Special Grid](https://leetcode.com/problems/fill-a-special-grid/) | [C++](./C++/fill-a-special-grid.cpp) [Python](./Python/fill-a-special-grid.py) | _O(4^n)_ | _O(1)_ | Medium | | Divide and Conquer, Array
3540 | [Minimum Time to Visit All Houses](https://leetcode.com/problems/minimum-time-to-visit-all-houses/) | [C++](./C++/minimum-time-to-visit-all-houses.cpp) [Python](./Python/minimum-time-to-visit-all-houses.py) | _O(n + q)_ | _O(n)_ | Medium | 🔒 | Prefix Sum
3546 | [Equal Sum Grid Partition I](https://leetcode.com/problems/equal-sum-grid-partition-i/) | [C++](./C++/equal-sum-grid-partition-i.cpp) [Python](./Python/equal-sum-grid-partition-i.py) | _O(m * n)_ | _O(1)_ | Medium | | Array
3548 | [Equal Sum Grid Partition II](https://leetcode.com/problems/equal-sum-grid-partition-ii/) | [C++](./C++/equal-sum-grid-partition-ii.cpp) [Python](./Python/equal-sum-grid-partition-ii.py) | _O(m * n)_ | _O(m * n)_ | Hard | | Array, Hash Table
3549 | [Multiply Two Polynomials](https://leetcode.com/problems/multiply-two-polynomials/) | [C++](./C++/multiply-two-polynomials.cpp) [Python](./Python/multiply-two-polynomials.py) | _O((n + m) * log(n + m))_ | _O(n + m)_ | Hard | 🔒 | `Fast Fourier Transform`, FFT
3550 | [Smallest Index With Digit Sum Equal to Index](https://leetcode.com/problems/smallest-index-with-digit-sum-equal-to-index/) | [C++](./C++/smallest-index-with-digit-sum-equal-to-index.cpp) [Python](./Python/smallest-index-with-digit-sum-equal-to-index.py) | _O(nlogr)_ | _O(1)_ | Easy | | Array
3569 | [Maximize Count of Distinct Primes After Split](https://leetcode.com/problems/maximize-count-of-distinct-primes-after-splitx/) | [C++](./C++/maximize-count-of-distinct-primes-after-split.cpp) [Python](./Python/maximize-count-of-distinct-primes-after-split.py) | _O(r + nlogn + qlogn)_ | _O(r + n)_ | Medium | | Number Theory, BST, Sorted List, Segment Tree
3637 | [Trionic Array I](https://leetcode.com/problems/trionic-array-i/) | [C++](./C++/trionic-array-i.cpp) [Python](./Python/trionic-array-i.py) | _O(n)_ | _O(1)_ | Easy | | Array
3643 | [Flip Square Submatrix Vertically](https://leetcode.com/problems/flip-square-submatrix-vertically/) | [C++](./C++/flip-square-submatrix-vertically.cpp) [Python](./Python/flip-square-submatrix-vertically.py) | _O(k^2)_ | _O(1)_ | Easy | | Array
3653 | [XOR After Range Multiplication Queries I](https://leetcode.com/problems/xor-after-range-multiplication-queries-i/) | [C++](./C++/xor-after-range-multiplication-queries-i.cpp) [Python](./Python/xor-after-range-multiplication-queries-i.py) | _O(qlogm + (q + n) * sqrt(n))_ | _O(n * sqrt(n))_ | Medium || Sqrt Decomposition, Difference Array, Fast Exponentiation, Simulation
3655 | [XOR After Range Multiplication Queries II](https://leetcode.com/problems/xor-after-range-multiplication-queries-ii/) | [C++](./C++/xor-after-range-multiplication-queries-ii.cpp) [Python](./Python/xor-after-range-multiplication-queries-ii.py) | _O(qlogm + (q + n) * sqrt(n))_ | _O(n * sqrt(n))_ | Hard || Sqrt Decomposition, Difference Array, Fast Exponentiation
3674 | [Minimum Operations to Equalize Array](https://leetcode.com/problems/minimum-operations-to-equalize-array/) | [C++](./C++/minimum-operations-to-equalize-array.cpp) [Python](./Python/minimum-operations-to-equalize-array.py) | _O(n)_ | _O(1)_ | Easy || Array
3683 | [Earliest Time to Finish One Task](https://leetcode.com/problems/earliest-time-to-finish-one-task/) | [C++](./C++/earliest-time-to-finish-one-task.cpp) [Python](./Python/earliest-time-to-finish-one-task.py) | _O(n)_ | _O(1)_ | Easy || Array
3687 | [Library Late Fee Calculator](https://leetcode.com/problems/library-late-fee-calculator/) | [C++](./C++/library-late-fee-calculator.cpp) [Python](./Python/library-late-fee-calculator.py) | _O(n)_ | _O(1)_ | Easy |🔒| Array
3688 | [Bitwise OR of Even Numbers in an Array](https://leetcode.com/problems/bitwise-or-of-even-numbers-in-an-array/) | [C++](./C++/bitwise-or-of-even-numbers-in-an-array.cpp) [Python](./Python/bitwise-or-of-even-numbers-in-an-array.py) | _O(n)_ | _O(1)_ | Easy || Array
3696 | [Maximum Distance Between Unequal Words in Array I](https://leetcode.com/problems/maximum-distance-between-unequal-words-in-array-i/) | [C++](./C++/maximum-distance-between-unequal-words-in-array-i.cpp) [Python](./Python/maximum-distance-between-unequal-words-in-array-i.py) | _O(n * l)_ | _O(1)_ | Easy |🔒| Array
3700 | [Number of ZigZag Arrays II](https://leetcode.com/problems/number-of-zigzag-arrays-ii/) | [C++](./C++/number-of-zigzag-arrays-ii.cpp) [Python](./Python/number-of-zigzag-arrays-ii.py) | _O((r - l)^3 * logn)_   | _O((r - l)^2)_        | Hard         | | Matrix Exponentiation
3701 | [Compute Alternating Sum](https://leetcode.com/problems/compute-alternating-sum/) | [C++](./C++/compute-alternating-sum.cpp) [Python](./Python/compute-alternating-sum.py) | _O(n)_ | _O(1)_ | Easy | | Array
3706 | [Maximum Distance Between Unequal Words in Array II](https://leetcode.com/problems/maximum-distance-between-unequal-words-in-array-ii/) | [C++](./C++/maximum-distance-between-unequal-words-in-array-ii.cpp) [Python](./Python/maximum-distance-between-unequal-words-in-array-ii.py) | _O(n * l)_ | _O(1)_ | Medium |🔒| Array
3707 | [Equal Score Substrings](https://leetcode.com/problems/equal-score-substrings/) | [C++](./C++/equal-score-substrings.cpp) [Python](./Python/equal-score-substrings.py) | _O(n)_ | _O(1)_ | Easy | | Array, Prefix Sum
3708 | [Longest Fibonacci Subarray](https://leetcode.com/problems/longest-fibonacci-subarray/) | [C++](./C++/longest-fibonacci-subarray.cpp) [Python](./Python/longest-fibonacci-subarray.py) | _O(n)_ | _O(1)_ | Medium | | Array
3719 | [Longest Balanced Subarray I](https://leetcode.com/problems/longest-balanced-subarray-i/) | [C++](./C++/longest-balanced-subarray-i.cpp) [Python](./Python/longest-balanced-subarray-i.py) | _O(nlogn)_ | _O(n)_ | Medium | | Brute Force, Segment Tree, Binary Search, Prefix Sum
3721 | [Longest Balanced Subarray II](https://leetcode.com/problems/longest-balanced-subarray-ii/) | [C++](./C++/longest-balanced-subarray-ii.cpp) [Python](./Python/longest-balanced-subarray-ii.py) | _O(nlogn)_ | _O(n)_ | Hard | | Segment Tree, Binary Search, Prefix Sum
3736 | [Minimum Moves to Equal Array Elements III](https://leetcode.com/problems/minimum-moves-to-equal-array-elements-iii/) | [C++](./C++/minimum-moves-to-equal-array-elements-iii.cpp) [Python](./Python/minimum-moves-to-equal-array-elements-iii.py) | _O(n)_ | _O(1)_ | Easy | | Array
3737 | [Count Subarrays With Majority Element I](https://leetcode.com/problems/count-subarrays-with-majority-element-i/) | [C++](./C++/count-subarrays-with-majority-element-i.cpp) [Python](./Python/count-subarrays-with-majority-element-i.py) | _O(n)_ | _O(n)_ | Medium | | Freq Table, Prefix Sum
3738 | [Longest Non-Decreasing Subarray After Replacing at Most One Element](https://leetcode.com/problems/longest-non-decreasing-subarray-after-replacing-at-most-one-element/) | [C++](./C++/longest-non-decreasing-subarray-after-replacing-at-most-one-element.cpp) [Python](./Python/longest-non-decreasing-subarray-after-replacing-at-most-one-element.py) | _O(n)_ | _O(n)_ | Medium | | Array, Prefix Sum
3739 | [Count Subarrays With Majority Element II](https://leetcode.com/problems/count-subarrays-with-majority-element-ii/) | [C++](./C++/count-subarrays-with-majority-element-ii.cpp) [Python](./Python/count-subarrays-with-majority-element-ii.py) | _O(n)_ | _O(n)_ | Hard | | Freq Table, Prefix Sum
3751 | [Total Waviness of Numbers in Range I](https://leetcode.com/problems/total-waviness-of-numbers-in-range-i/) | [C++](./C++/total-waviness-of-numbers-in-range-i.cpp) [Python](./Python/total-waviness-of-numbers-in-range-i.py) | _O(nlogn)_ | _O(logn)_ | Medium | | Brute Force
3756 | [Concatenate Non-Zero Digits and Multiply by Sum II](https://leetcode.com/problems/concatenate-non-zero-digits-and-multiply-by-sum-ii/) | [C++](./C++/concatenate-non-zero-digits-and-multiply-by-sum-ii.cpp) [Python](./Python/concatenate-non-zero-digits-and-multiply-by-sum-ii.py) | _O(n)_ | _O(n)_ | Medium | | Prefix Sum |
3762 | [Minimum Operations to Equalize Subarrays](https://leetcode.com/problems/minimum-operations-to-equalize-subarrays/) | [C++](./C++/minimum-operations-to-equalize-subarrays.cpp) [Python](./Python/minimum-operations-to-equalize-subarrays.py) | _O((n + q) * logn)_ | _O(nlogn)_ | Hard | | Prefix Sum, Coordinate Compression, Persistent Segment Tree, Binary Search |
3774 | [Absolute Difference Between Maximum and Minimum K Elements](https://leetcode.com/problems/absolute-difference-between-maximum-and-minimum-k-elements/) | [C++](./C++/absolute-difference-between-maximum-and-minimum-k-elements.cpp) [Python](./Python/absolute-difference-between-maximum-and-minimum-k-elements.py) | _O(n)_ | _O(1)_ | Easy | | Sort, Quick Select
3788 | [Maximum Score of a Split](https://leetcode.com/problems/maximum-score-of-a-split/) | [C++](./C++/maximum-score-of-a-split.cpp) [Python](./Python/maximum-score-of-a-split.py) | _O(n)_ | _O(1)_ | Medium | | Prefix Sum
3809 | [Best Reachable Tower](https://leetcode.com/problems/best-reachable-tower/) | [C++](./C++/best-reachable-tower.cpp) [Python](./Python/best-reachable-tower.py) | _O(n)_ | _O(1)_ | Medium | | Array
3814 | [Maximum Capacity Within Budget](https://leetcode.com/problems/maximum-capacity-within-budget/) | [C++](./C++/maximum-capacity-within-budget.cpp) [Python](./Python/maximum-capacity-within-budget.py) | _O(n + b)_ | _O(b)_ | Medium | | Hash Table, Prefix Sum, Sort, Mono Stack, Binary Search
3818 | [Minimum Prefix Removal to Make Array Strictly Increasing](https://leetcode.com/problems/minimum-prefix-removal-to-make-array-strictly-increasing/) | [C++](./C++/minimum-prefix-removal-to-make-array-strictly-increasing.cpp) [Python](./Python/minimum-prefix-removal-to-make-array-strictly-increasing.py) | _O(n)_ | _O(1)_ | Medium | | Array
3819 | [Rotate Non Negative Elements](https://leetcode.com/problems/rotate-non-negative-elements/) | [C++](./C++/rotate-non-negative-elements.cpp) [Python](./Python/rotate-non-negative-elements.py) | _O(n)_ | _O(n)_ | Medium | | Array
3833 | [Count Dominant Indices](https://leetcode.com/problems/count-dominant-indices/) | [C++](./C++/count-dominant-indices.cpp) [Python](./Python/count-dominant-indices.py) | _O(n)_ | _O(1)_ | Easy | | Array
3861 | [Minimum Capacity Box](https://leetcode.com/problems/minimum-capacity-box/) | [C++](./C++/minimum-capacity-box.cpp) [Python](./Python/minimum-capacity-box.py) | _O(n)_ | _O(1)_ | Easy | | Array
3862 | [Find the Smallest Balanced Index](https://leetcode.com/problems/find-the-smallest-balanced-index/) | [C++](./C++/find-the-smallest-balanced-index.cpp) [Python](./Python/find-the-smallest-balanced-index.py) | _O(n)_ | _O(1)_ | Medium | | Prefix Sum
3865 | [Reverse K Subarrays](https://leetcode.com/problems/reverse-k-subarrays/) | [C++](./C++/reverse-k-subarrays.cpp) [Python](./Python/reverse-k-subarrays.py) | _O(n)_ | _O(1)_ | Medium | 🔒 | Array
3880 | [Minimum Absolute Difference Between Two Values](https://leetcode.com/problems/minimum-absolute-difference-between-two-values/) | [C++](./C++/minimum-absolute-difference-between-two-values.cpp) [Python](./Python/minimum-absolute-difference-between-two-values.py) | _O(n)_ | _O(1)_ | Easy | | Array
3886 | [Sum of Sortable Integers](https://leetcode.com/problems/sum-of-sortable-integers/) | [C++](./C++/sum-of-sortable-integers.cpp) [Python](./Python/sum-of-sortable-integers.py) | _O(nlog(logn))_ | _O(n)_ | Hard | | Prefix Sum, Number Theory
3898 | [Find the Degree of Each Vertex](https://leetcode.com/problems/find-the-degree-of-each-vertex/) | [C++](./C++/find-the-degree-of-each-vertex.cpp) [Python](./Python/find-the-degree-of-each-vertex.py) | _O(n * m)_ | _O(1)_ | Easy | | Array
3903 | [Smallest Stable Index I](https://leetcode.com/problems/smallest-stable-index-i/) | [C++](./C++/smallest-stable-index-i.cpp) [Python](./Python/smallest-stable-index-i.py) | _O(n)_ | _O(n)_ | Easy | | Prefix Sum
3904 | [Smallest Stable Index II](https://leetcode.com/problems/smallest-stable-index-ii/) | [C++](./C++/smallest-stable-index-ii.cpp) [Python](./Python/smallest-stable-index-ii.py) | _O(n)_ | _O(n)_ | Medium | | Prefix Sum
3907 | [Count Smaller Elements With Opposite Parity](https://leetcode.com/problems/count-smaller-elements-with-opposite-parity/) | [C++](./C++/count-smaller-elements-with-opposite-parity.cpp) [Python](./Python/count-smaller-elements-with-opposite-parity.py) | _O(nlogn)_ | _O(n)_ | Medium | 🔒 | Sort, Coordinate Compression, BIT, Fenwick Tree
3909 | [Compare Sums of Bitonic Parts](https://leetcode.com/problems/compare-sums-of-bitonic-parts/) | [C++](./C++/compare-sums-of-bitonic-parts.cpp) [Python](./Python/compare-sums-of-bitonic-parts.py) | _O(n)_ | _O(1)_ | Medium | | Array
3912 | [Valid Elements in an Array](https://leetcode.com/problems/valid-elements-in-an-array/) | [C++](./C++/valid-elements-in-an-array.cpp) [Python](./Python/valid-elements-in-an-array.py) | _O(n)_ | _O(n)_ | Medium | | Prefix Sum
3915 | [Maximum Sum of Alternating Subsequence With Distance at Least K](https://leetcode.com/problems/minimum-operations-to-make-array-non-decreasing/) | [C++](./C++/minimum-operations-to-make-array-non-decreasing.cpp) [Python](./Python/minimum-operations-to-make-array-non-decreasing.py) | _O(nlogn)_ | _O(n)_ | Hard | | Sort, Coordinate Compression, BIT, Fenwick Tree, Sliding Window, DP
3918 | [Sum of Primes Between Number and Its Reverse](https://leetcode.com/problems/sum-of-primes-between-number-and-its-reverse/) | [C++](./C++/sum-of-primes-between-number-and-its-reverse.cpp) [Python](./Python/sum-of-primes-between-number-and-its-reverse.py) | precompute: _O(r)_runtime: _O(1)_ | _O(r)_ | Medium | | Number Theory, `Linear Sieve of Eratosthenes`, Prefix Sum
3925 | [Concatenate Array With Reverse](https://leetcode.com/problems/concatenate-array-with-reverse/) | [C++](./C++/concatenate-array-with-reverse.cpp) [Python](./Python/concatenate-array-with-reverse.py) | _O(n)_ | _O(1)_ | Easy | | Array
3933 | [Largest Local Values in a Matrix II](https://leetcode.com/problems/largest-local-values-in-a-matrix-ii/) | [C++](./C++/largest-local-values-in-a-matrix-ii.cpp) [Python](./Python/largest-local-values-in-a-matrix-ii.py) | _O(n * m * logn * logm)_ | _O(n * m * logn * logm)_ | Medium | | RMQ, 2D Sparse Table
3936 | [Minimum Swaps to Move Zeros to End](https://leetcode.com/problems/minimum-swaps-to-move-zeros-to-end/) | [C++](./C++/minimum-swaps-to-move-zeros-to-end.cpp) [Python](./Python/minimum-swaps-to-move-zeros-to-end.py) | _O(n)_ | _O(1)_ | Easy | | Array
3938 | [Maximum Path Intersection Sum in a Grid](https://leetcode.com/problems/maximum-path-intersection-sum-in-a-grid/) | [C++](./C++/maximum-path-intersection-sum-in-a-grid.cpp) [Python](./Python/maximum-path-intersection-sum-in-a-grid.py) | _O(n * m)_ | _O(1)_ | Medium | | Array, `Kadane's Algorithm`
3940 | [Limit Occurrences in Sorted Array](https://leetcode.com/problems/limit-occurrences-in-sorted-array/) | [C++](./C++/limit-occurrences-in-sorted-array.cpp) [Python](./Python/limit-occurrences-in-sorted-array.py) | _O(n)_ | _O(1)_ | Easy | | Array, Inplace
3942 | [Minimum Operations to Sort a Permutation](https://leetcode.com/problems/minimum-operations-to-sort-a-permutation/) | [C++](./C++/minimum-operations-to-sort-a-permutation.cpp) [Python](./Python/minimum-operations-to-sort-a-permutation.py) | _O(n)_ | _O(1)_ | Medium | | Array
3943 | [Number of Pairs After Increment](https://leetcode.com/problems/number-of-pairs-after-increment/) | [C++](./C++/number-of-pairs-after-increment.cpp) [Python](./Python/number-of-pairs-after-increment.py) | _O(n + m + q * sqrt(m * n))_ | _O(n + m)_ | Hard || Freq Table, Sqrt Decomposition
3951 | [Minimum Energy to Maintain Brightness](https://leetcode.com/problems/minimum-energy-to-maintain-brightness/) | [C++](./C++/minimum-energy-to-maintain-brightness.cpp) [Python](./Python/minimum-energy-to-maintain-brightness.py) | _O(nlogn)_ | _O(1)_ | Medium | | Sort, Line Sweep
3951 | [Minimum Energy to Maintain Brightness](https://leetcode.com/problems/minimum-energy-to-maintain-brightness/) | [C++](./C++/minimum-energy-to-maintain-brightness.cpp) [Python](./Python/minimum-energy-to-maintain-brightness.py) | _O(nlogn)_ | _O(1)_ | Medium | | Sort, Line Sweep
3963 | [Create Grid With Exactly One Path](https://leetcode.com/problems/create-grid-with-exactly-one-path/) | [C++](./C++/create-grid-with-exactly-one-path.cpp) [Python](./Python/create-grid-with-exactly-one-path.py) | _O(m * n)_ | _O(1)_ | Easy | | Array
3978 | [Unique Middle Element](https://leetcode.com/problems/unique-middle-element/) | [C++](./C++/unique-middle-element.cpp) [Python](./Python/unique-middle-element.py) | _O(n)_ | _O(1)_ | Easy | | Array
3979 | [Maximum Valid Pair Sum](https://leetcode.com/problems/maximum-valid-pair-sum/) | [C++](./C++/maximum-valid-pair-sum.cpp) [Python](./Python/maximum-valid-pair-sum.py) | _O(n)_ | _O(n)_ | Medium | | Prefix Sum
3982 | [Sum of Integers with Maximum Digit Range](https://leetcode.com/problems/sum-of-integers-with-maximum-digit-range/) | [C++](./C++/sum-of-integers-with-maximum-digit-range.cpp) [Python](./Python/sum-of-integers-with-maximum-digit-range.py) | _O(nlogr)_ | _O(1)_ | Easy | | Array
3985 | [Palindromic Subarray Sum](https://leetcode.com/problems/palindromic-subarray-sum/) | [C++](./C++/palindromic-subarray-sum.cpp) [Python](./Python/palindromic-subarray-sum.py) | _O(n)_ | _O(n)_ | Hard | | Prefix Sum, `Manacher's Algorithm`
3998 | [Transform Binary String Using Subsequence Sort](https://leetcode.com/problems/transform-binary-string-using-subsequence-sort/) | [C++](./C++/transform-binary-string-using-subsequence-sort.cpp) [Python](./Python/transform-binary-string-using-subsequence-sort.py) | _O(n * m)_ | _O(n)_ | Hard | | Prefix Sum
4006 | [Count Valid Prefixes](https://leetcode.com/problems/count-valid-prefixes/) | [C++](./C++/count-valid-prefixes.cpp) [Python](./Python/count-valid-prefixes.py) | _O(n)_ | _O(1)_ | Easy | | Prefix Sum
4010 | [Maximize Pair Strength Using GCD](https://leetcode.com/problems/maximize-pair-strength-using-gcd/) | [C++](./C++/maximize-pair-strength-using-gcd.cpp) [Python](./Python/maximize-pair-strength-using-gcd.py) | _O(n^2 * logr)_ | _O(1)_ | Easy | | Brute Force, Sort, Pruning
4011 | [Count Subarrays With Even Odd Ratio I](https://leetcode.com/problems/count-subarrays-with-even-odd-ratio-i/) | [C++](./C++/count-subarrays-with-even-odd-ratio-i.cpp) [Python](./Python/count-subarrays-with-even-odd-ratio-i.py) | _O(nlogn)_ | _O(n)_ | Medium | | Prefix Sum, Sort, Coordinate Compression, BIT, Fenwick Tree, Brute Force
4012 | [Count of Unfinished Tasks After Each Shift](https://leetcode.com/problems/count-of-unfinished-tasks-after-each-shift/) | [C++](./C++/count-of-unfinished-tasks-after-each-shift.cpp) [Python](./Python/count-of-unfinished-tasks-after-each-shift.py) | _O(n + mlogn)_ | _O(n)_ | Medium | | Prefix Sum, Binary Search
4013 | [Count Subarrays With Even Odd Ratio II](https://leetcode.com/problems/count-subarrays-with-even-odd-ratio-ii/) | [C++](./C++/count-subarrays-with-even-odd-ratio-ii.cpp) [Python](./Python/count-subarrays-with-even-odd-ratio-ii.py) | _O(nlogn)_ | _O(n)_ | Hard | | Prefix Sum, Sort, Coordinate Compression, BIT, Fenwick Tree
4017 | [Peaks in Array II](https://leetcode.com/problems/peaks-in-array-ii/) | [C++](./C++/peaks-in-array-ii.cpp) [Python](./Python/peaks-in-array-ii.py) | _O(nlogn + qlogn)_ | _O(n)_ | Hard | | BIT, Fenwick Tree



    **[⬆️ Back to Top](#algorithms)**



## String
|  #  | Title           |  Solution       |  Time           | Space           | Difficulty    | Tag          | Note| 
|-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------|-----|
3019 | [Number of Changing Keys](https://leetcode.com/problems/number-of-changing-keys/)| [C++](./C++/number-of-changing-keys.cpp) [Python](./Python/number-of-changing-keys.py)| _O(n)_ | _O(1)_ | Easy | | String |
3023 | [Find Pattern in Infinite Stream I](https://leetcode.com/problems/find-pattern-in-infinite-stream-i/)| [C++](./C++/find-pattern-in-infinite-stream-i.cpp) [Python](./Python/find-pattern-in-infinite-stream-i.py)| _O(p + n)_ | _O(p)_ | Medium | 🔒 | String, `KMP Algorithm` |
3029 | [Minimum Time to Revert Word to Initial State I](https://leetcode.com/problems/minimum-time-to-revert-word-to-initial-state-i/)| [C++](./C++/minimum-time-to-revert-word-to-initial-state-i.cpp) [Python](./Python/minimum-time-to-revert-word-to-initial-state-i.py)| _O(n)_ | _O(n)_ | Medium | | String, `Z-Function`, Brute Force |
3031 | [Minimum Time to Revert Word to Initial State II](https://leetcode.com/problems/minimum-time-to-revert-word-to-initial-state-ii/)| [C++](./C++/minimum-time-to-revert-word-to-initial-state-ii.cpp) [Python](./Python/minimum-time-to-revert-word-to-initial-state-ii.py)| _O(n)_ | _O(n)_ | Hard | | String, `Z-Function` |
3034 | [Number of Subarrays That Match a Pattern I](https://leetcode.com/problems/number-of-subarrays-that-match-a-pattern-i/)| [C++](./C++/number-of-subarrays-that-match-a-pattern-i.cpp) [Python](./Python/number-of-subarrays-that-match-a-pattern-i.py)| _O(n)_ | _O(m)_ | Medium | | Brute Force, String, `KMP Algorithm` |
3036 | [Number of Subarrays That Match a Pattern II](https://leetcode.com/problems/number-of-subarrays-that-match-a-pattern-ii/)| [C++](./C++/number-of-subarrays-that-match-a-pattern-ii.cpp) [Python](./Python/number-of-subarrays-that-match-a-pattern-ii.py)| _O(n)_ | _O(m)_ | Hard | | String, `KMP Algorithm` |
3037 | [Find Pattern in Infinite Stream II](https://leetcode.com/problems/find-pattern-in-infinite-stream-ii/)| [C++](./C++/find-pattern-in-infinite-stream-ii.cpp) [Python](./Python/find-pattern-in-infinite-stream-ii.py)| _O(p + n)_ | _O(p)_ | Hard | 🔒 | String, `KMP Algorithm` |
3042 | [Count Prefix and Suffix Pairs I](https://leetcode.com/problems/count-prefix-and-suffix-pairs-i/)| [C++](./C++/count-prefix-and-suffix-pairs-i.cpp) [Python](./Python/count-prefix-and-suffix-pairs-i.py)| _O(n * l)_ | _O(t)_ | Easy | | Trie, Brute Force |
3043 | [Find the Length of the Longest Common Prefix](https://leetcode.com/problems/find-the-length-of-the-longest-common-prefix/)| [C++](./C++/find-the-length-of-the-longest-common-prefix.cpp) [Python](./Python/find-the-length-of-the-longest-common-prefix.py)| _O((n + m) * l)_ | _O(t)_ | Medium | | Trie, Hash Table |
3045 | [Count Prefix and Suffix Pairs II](https://leetcode.com/problems/count-prefix-and-suffix-pairs-ii/)| [C++](./C++/count-prefix-and-suffix-pairs-ii.cpp) [Python](./Python/count-prefix-and-suffix-pairs-ii.py)| _O(n * l)_ | _O(t)_ | Hard | | Trie |
3076 | [Shortest Uncommon Substring in an Array](https://leetcode.com/problems/shortest-uncommon-substring-in-an-array/)| [C++](./C++/shortest-uncommon-substring-in-an-array.cpp) [Python](./Python/shortest-uncommon-substring-in-an-array.py)| _O(n * l^2)_ | _O(t)_ | Medium | | Trie |
3093 | [Longest Common Suffix Queries](https://leetcode.com/problems/longest-common-suffix-queries/)| [C++](./C++/longest-common-suffix-queries.cpp) [Python](./Python/longest-common-suffix-queries.py)| _O((n + q) * l)_ | _O(t)_ | Hard | | Trie |
3110 | [Score of a String](https://leetcode.com/problems/score-of-a-string/)| [C++](./C++/score-of-a-string.cpp) [Python](./Python/score-of-a-string.py)| _O(n)_ | _O(1)_ | Easy | | String |
3136 | [Valid Word](https://leetcode.com/problems/valid-word/) | [C++](./C++/valid-word.cpp) [Python](./Python/valid-word.py) | _O(n)_ | _O(1)_ | Easy | | String
3163 | [String Compression III](https://leetcode.com/problems/string-compression-iii/) | [C++](./C++/string-compression-iii.cpp) [Python](./Python/string-compression-iii.py) | _O(n)_ | _O(1)_ | Medium | | String
3210 | [Find the Encrypted String](https://leetcode.com/problems/find-the-encrypted-string/) | [C++](./C++/find-the-encrypted-string.cpp) [Python](./Python/find-the-encrypted-string.py) | _O(n)_ | _O(1)_ | Medium | | String
3271 | [Hash Divided String](https://leetcode.com/problems/hash-divided-string/) | [C++](./C++/hash-divided-string.cpp) [Python](./Python/hash-divided-string.py) | _O(n)_ | _O(1)_ | Medium | | String
3280 | [Convert Date to Binary](https://leetcode.com/problems/convert-date-to-binary/) | [C++](./C++/convert-date-to-binary.cpp) [Python](./Python/convert-date-to-binary.py) | _O(1)_ | _O(1)_ | Easy | | String
3303 | [Find the Occurrence of First Almost Equal Substring](https://leetcode.com/problems/find-the-occurrence-of-first-almost-equal-substring/) | [C++](./C++/find-the-occurrence-of-first-almost-equal-substring.cpp) [Python](./Python/find-the-occurrence-of-first-almost-equal-substring.py) | _O(n + m)_   | _O(n + m)_        | Hard         | | `Z-Function`
3324 | [Find the Sequence of Strings Appeared on the Screen](https://leetcode.com/problems/find-the-sequence-of-strings-appeared-on-the-screen/) | [C++](./C++/find-the-sequence-of-strings-appeared-on-the-screen.cpp) [Python](./Python/find-the-sequence-of-strings-appeared-on-the-screen.py) | _O(n^2)_   | _O(1)_        | Medium         | | String
3340 | [Check Balanced String](https://leetcode.com/problems/check-balanced-string/) | [C++](./C++/check-balanced-string.cpp) [Python](./Python/check-balanced-string.py) | _O(n)_   | _O(1)_        | Easy         | | String
3407 | [Substring Matching Pattern](https://leetcode.com/problems/substring-matching-pattern/) | [C++](./C++/substring-matching-pattern.cpp) [Python](./Python/substring-matching-pattern.py) | _O(n + m)_   | _O(m)_        | Easy         | | String, `KMP Algorithm`
3455 | [Shortest Matching Substring](https://leetcode.com/problems/shortest-matching-substring/) | [C++](./C++/shortest-matching-substring.cpp) [Python](./Python/shortest-matching-substring.py) | _O(n + m)_   | _O(n + m)_        | Hard         | | String, `KMP Algorithm`, Two Pointers
3456 | [Find Special Substring of Length K](https://leetcode.com/problems/find-special-substring-of-length-k/) | [C++](./C++/find-special-substring-of-length-k.cpp) [Python](./Python/find-special-substring-of-length-k.py) | _O(n)_   | _O(1)_        | Easy         | | String
3491 | [Phone Number Prefix](https://leetcode.com/problems/phone-number-prefix/) | [C++](./C++/phone-number-prefix.cpp) [Python](./Python/phone-number-prefix.py) | _O(l * nlogn)_   | _O(1)_        | Easy         | 🔒 | Trie, Sort
3498 | [Reverse Degree of a String](https://leetcode.com/problems/reverse-degree-of-a-string/) | [C++](./C++/reverse-degree-of-a-string.cpp) [Python](./Python/reverse-degree-of-a-string.py) | _O(n)_   | _O(1)_        | Easy         | | String
3529 | [Count Cells in Overlapping Horizontal and Vertical Substrings](https://leetcode.com/problems/count-cells-in-overlapping-horizontal-and-vertical-substrings/) | [C++](./C++/count-cells-in-overlapping-horizontal-and-vertical-substrings.cpp) [Python](./Python/count-cells-in-overlapping-horizontal-and-vertical-substrings.py) | _O(n * m)_ | _O(n * m)_ | Medium | | `Z-Function`
3571 | [Find the Shortest Superstring II](https://leetcode.com/problems/find-the-shortest-superstring-ii/) | [C++](./C++/find-the-shortest-superstring-ii.cpp) [Python](./Python/find-the-shortest-superstring-ii.py) | _O(n + m)_ | _O(n + m)_ | Easy | 🔒 | `KMP Algorithm`
3582 | [Generate Tag for Video Caption](https://leetcode.com/problems/generate-tag-for-video-caption/) | [C++](./C++/generate-tag-for-video-caption.cpp) [Python](./Python/generate-tag-for-video-caption.py) | _O(n)_ | _O(1)_ | Easy | | String
3598 | [Longest Common Prefix Between Adjacent Strings After Removals](https://leetcode.com/problems/longest-common-prefix-between-adjacent-strings-after-removals/) | [C++](./C++/longest-common-prefix-between-adjacent-strings-after-removals.cpp) [Python](./Python/longest-common-prefix-between-adjacent-strings-after-removals.py) | _O(n * l)_ | _O(n)_ | Medium | | LCP, Prefix Sum
3606 | [Coupon Code Validator](https://leetcode.com/problems/coupon-code-validator/) | [C++](./C++/coupon-code-validator.cpp) [Python](./Python/coupon-code-validator.py) | _O(l * nlogn)_ | _O(n * l)_ | Easy | | Hash Table, Sort
3744 | [Find Kth Character in Expanded String](https://leetcode.com/problems/find-kth-character-in-expanded-string/) | [C++](./C++/find-kth-character-in-expanded-string.cpp) [Python](./Python/find-kth-character-in-expanded-string.py) | _O(n)_ | _O(1)_ | Medium | 🔒 | String
3746 | [Minimum String Length After Balanced Removals](https://leetcode.com/problems/minimum-string-length-after-balanced-removals/) | [C++](./C++/minimum-string-length-after-balanced-removals.cpp) [Python](./Python/minimum-string-length-after-balanced-removals.py) | _O(n)_ | _O(1)_ | Medium | | String
3748 | [Count Stable Subarrays](https://leetcode.com/problems/count-stable-subarrays/) | [C++](./C++/count-stable-subarrays.cpp) [Python](./Python/count-stable-subarrays.py) | _O(n + q)_ | _O(n)_ | Hard | | Prefix Sum
3758 | [Convert Number Words to Digits](https://leetcode.com/problems/convert-number-words-to-digits/) | [C++](./C++/convert-number-words-to-digits.cpp) [Python](./Python/convert-number-words-to-digits.py) | _O(n)_ | _O(1)_ | Medium | 🔒 | String
3775 | [Reverse Words With Same Vowel Count](https://leetcode.com/problems/reverse-words-with-same-vowel-count/) | [C++](./C++/reverse-words-with-same-vowel-count.cpp) [Python](./Python/reverse-words-with-same-vowel-count.py) | _O(n)_ | _O(1)_ | Medium | | String, Inplace
3777 | [Minimum Deletions to Make Alternating Substring](https://leetcode.com/problems/minimum-deletions-to-make-alternating-substring/) | [C++](./C++/minimum-deletions-to-make-alternating-substring.cpp) [Python](./Python/minimum-deletions-to-make-alternating-substring.py) | _O((n + q) * logn)_ | _O(n)_ | Hard | | BIT, Fenwick Tree
3794 | [Reverse String Prefix](https://leetcode.com/problems/reverse-string-prefix/) | [C++](./C++/reverse-string-prefix.cpp) [Python](./Python/reverse-string-prefix.py) | _O(n)_ | _O(1)_ | Easy | | String
3813 | [Vowel-Consonant Score](https://leetcode.com/problems/vowel-consonant-score/) | [C++](./C++/vowel-consonant-score.cpp) [Python](./Python/vowel-consonant-score.py) | _O(n)_ | _O(1)_ | Easy | | String
3823 | [Reverse Letters Then Special Characters in a String](https://leetcode.com/problems/reverse-letters-then-special-characters-in-a-string/) | [C++](./C++/reverse-letters-then-special-characters-in-a-string.cpp) [Python](./Python/reverse-letters-then-special-characters-in-a-string.py) | _O(n)_ | _O(1)_ | Easy | | String
3838 | [Weighted Word Mapping](https://leetcode.com/problems/weighted-word-mapping/) | [C++](./C++/weighted-word-mapping.cpp) [Python](./Python/weighted-word-mapping.py) | _O(n * l)_ | _O(1)_ | Easy | | String
3856 | [Trim Trailing Vowels](https://leetcode.com/problems/trim-trailing-vowels/) | [C++](./C++/trim-trailing-vowels.cpp) [Python](./Python/trim-trailing-vowels.py) | _O(n)_ | _O(1)_ | Easy | | String
3860 | [Unique Email Groups](https://leetcode.com/problems/unique-email-groups/) | [C++](./C++/unique-email-groups.cpp) [Python](./Python/unique-email-groups.py) | _O(n * l)_ | _O(n * l)_ | Medium | 🔒 | String, Hash Table
3884 | [First Matching Character From Both Ends](https://leetcode.com/problems/first-matching-character-from-both-ends/) | [C++](./C++/first-matching-character-from-both-ends.cpp) [Python](./Python/first-matching-character-from-both-ends.py) | _O(n)_ | _O(1)_ | Medium | | String
3931 | [Check Adjacent Digit Differences](https://leetcode.com/problems/check-adjacent-digit-differences/) | [C++](./C++/check-adjacent-digit-differences.cpp) [Python](./Python/check-adjacent-digit-differences.py) | _O(n)_ | _O(1)_ | Easy | | String
3941 | [Password Strength](https://leetcode.com/problems/password-strength/) | [C++](./C++/password-strength.cpp) [Python](./Python/password-strength.py) | _O(n)_ | _O(1)_ | Medium | | String, Hash Table
3986 | [Number of Elapsed Seconds Between Two Times](https://leetcode.com/problems/number-of-elapsed-seconds-between-two-times/) | [C++](./C++/number-of-elapsed-seconds-between-two-times.cpp) [Python](./Python/number-of-elapsed-seconds-between-two-times.py) | _O(1)_ | _O(1)_ | Easy | | String
3999 | [Minimum Number of String Groups Through Transformations](https://leetcode.com/problems/minimum-number-of-string-groups-through-transformations/) | [C++](./C++/minimum-number-of-string-groups-through-transformations.cpp) [Python](./Python/minimum-number-of-string-groups-through-transformations.py) | _O(n * l)_ | _O(n * l)_ | Hard | | Hash Table, String



    **[⬆️ Back to Top](#algorithms)**



## Linked List
|  #  | Title           |  Solution       |  Time           | Space           | Difficulty    | Tag          | Note| 
|-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------|-----|
3062 | [Winner of the Linked List Game](https://leetcode.com/problems/winner-of-the-linked-list-game/) | [C++](./C++/winner-of-the-linked-list-game.cpp) [Python](./Python/winner-of-the-linked-list-game.py) | _O(n)_ | _O(1)_ | Easy | 🔒 | Linked List
3063 | [Linked List Frequency](https://leetcode.com/problems/linked-list-frequency/) | [C++](./C++/linked-list-frequency.cpp) [Python](./Python/linked-list-frequency.py) | _O(n)_ | _O(1)_ | Medium | 🔒 | Linked List
3217 | [Delete Nodes From Linked List Present in Array](https://leetcode.com/problems/delete-nodes-from-linked-list-present-in-array/) | [C++](./C++/delete-nodes-from-linked-list-present-in-array.cpp) [Python](./Python/delete-nodes-from-linked-list-present-in-array.py) | _O(n)_ | _O(m)_ | Medium | | Hash Table, Linked List
3263 | [Convert Doubly Linked List to Array I](https://leetcode.com/problems/convert-doubly-linked-list-to-array-i/) | [C++](./C++/convert-doubly-linked-list-to-array-i.cpp) [Python](./Python/convert-doubly-linked-list-to-array-i.py) | _O(n)_ | _O(1)_ | Easy | 🔒 | Linked List
3294 | [Convert Doubly Linked List to Array II](https://leetcode.com/problems/convert-doubly-linked-list-to-array-ii/) | [C++](./C++/convert-doubly-linked-list-to-array-ii.cpp) [Python](./Python/convert-doubly-linked-list-to-array-ii.py) | _O(n)_ | _O(1)_ | Medium | 🔒 | Linked List



    **[⬆️ Back to Top](#algorithms)**



## Stack
|  #  | Title           |  Solution       |  Time           | Space           | Difficulty    | Tag          | Note| 
|-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------|-----|
3113 | [Find the Number of Subarrays Where Boundary Elements Are Maximum](https://leetcode.com/problems/find-the-number-of-subarrays-where-boundary-elements-are-maximum/) | [C++](./C++/find-the-number-of-subarrays-where-boundary-elements-are-maximum.cpp) [Python](./Python/find-the-number-of-subarrays-where-boundary-elements-are-maximum.py) | _O(n)_ | _O(n)_ | Hard | | Mono Stack, Combinatorics
3174 | [Clear Digits](https://leetcode.com/problems/clear-digits/) | [C++](./C++/clear-digits.cpp) [Python](./Python/clear-digits.py) | _O(n)_ | _O(1)_ | Easy | | Stack, Two Pointers
3676 | [Count Bowl Subarrays](https://leetcode.com/problems/count-bowl-subarrays/) | [C++](./C++/count-bowl-subarrays.cpp) [Python](./Python/count-bowl-subarrays.py) | _O(n)_ | _O(n)_ | Medium | | Mono Stack
3703 | [Remove K-Balanced Substrings](https://leetcode.com/problems/remove-k-balanced-substrings/) | [C++](./C++/remove-k-balanced-substrings.cpp) [Python](./Python/remove-k-balanced-substrings.py) | _O(n)_ | _O(n)_ | Medium | | Stack
3749 | [Evaluate Valid Expressions](https://leetcode.com/problems/evaluate-valid-expressions/) | [C++](./C++/evaluate-valid-expressions.cpp) [Python](./Python/evaluate-valid-expressions.py) | _O(n)_ | _O(n)_ | Hard | 🔒 | Stack
3834 | [Merge Adjacent Equal Elements](https://leetcode.com/problems/merge-adjacent-equal-elements/) | [C++](./C++/merge-adjacent-equal-elements.cpp) [Python](./Python/merge-adjacent-equal-elements.py) | _O(n)_ | _O(1)_ | Medium | | Stack, Simulation
3878 | [Count Good Subarrays](https://leetcode.com/problems/count-good-subarrays/) | [C++](./C++/count-good-subarrays.cpp) [Python](./Python/count-good-subarrays.py) | _O(n)_ | _O(n)_ | Hard | | Combinatorics, Mono Stack



    **[⬆️ Back to Top](#algorithms)**



## Queue
|  #  | Title           |  Solution       |  Time           | Space           | Difficulty    | Tag          | Note| 
|-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------|-----|



    **[⬆️ Back to Top](#algorithms)**



## Binary Heap
|  #  | Title           |  Solution       |  Time           | Space           | Difficulty    | Tag          | Note| 
|-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------|-----|
3066 | [Minimum Operations to Exceed Threshold Value II](https://leetcode.com/problems/minimum-operations-to-exceed-threshold-value-ii/) | [C++](./C++/minimum-operations-to-exceed-threshold-value-ii.cpp) [Python](./Python/minimum-operations-to-exceed-threshold-value-ii.py) | _O(nlogn)_ | _O(n)_ | Medium | | Simulation, Heap
3080 | [Mark Elements on Array by Performing Queries](https://leetcode.com/problems/mark-elements-on-array-by-performing-queries/) | [C++](./C++/mark-elements-on-array-by-performing-queries.cpp) [Python](./Python/mark-elements-on-array-by-performing-queries.py) | _O(q + nlogn)_ | _O(n)_ | Medium | | Hash Table, Heap
3092 | [Most Frequent IDs](https://leetcode.com/problems/most-frequent-ids/) | [C++](./C++/most-frequent-ids.cpp) [Python](./Python/most-frequent-ids.py) | _O(nlogn)_ | _O(n)_ | Medium | | Heap, BST, Sorted List
3256 | [Maximum Value Sum by Placing Three Rooks I](https://leetcode.com/problems/maximum-value-sum-by-placing-three-rooks-i/) | [C++](./C++/maximum-value-sum-by-placing-three-rooks-i.cpp) [Python](./Python/maximum-value-sum-by-placing-three-rooks-i.py) | _O(m * n)_ | _O(m + n)_ | Hard | | Heap, Brute Force
3257 | [Maximum Value Sum by Placing Three Rooks II](https://leetcode.com/problems/maximum-value-sum-by-placing-three-rooks-ii/) | [C++](./C++/maximum-value-sum-by-placing-three-rooks-ii.cpp) [Python](./Python/maximum-value-sum-by-placing-three-rooks-ii.py) | _O(m * n)_ | _O(m + n)_ | Hard | | Heap, Brute Force
3275 | [K-th Nearest Obstacle Queries](https://leetcode.com/problems/k-th-nearest-obstacle-queries/) | [C++](./C++/k-th-nearest-obstacle-queries.cpp) [Python](./Python/k-th-nearest-obstacle-queries.py) | _O(qlogk)_ | _O(k)_ | Medium | | Heap
3684 | [Maximize Sum of At Most K Distinct Elements](https://leetcode.com/problems/maximize-sum-of-at-most-k-distinct-elements/) | [C++](./C++/maximize-sum-of-at-most-k-distinct-elements.cpp) [Python](./Python/maximize-sum-of-at-most-k-distinct-elements.py) | _O(nlogk)_ | _O(k)_ | Easy | | Heap, Sort
3691 | [Maximum Total Subarray Value II](https://leetcode.com/problems/maximum-total-subarray-value-ii/) | [C++](./C++/maximum-total-subarray-value-ii.cpp) [Python](./Python/maximum-total-subarray-value-ii.py) | _O((n + k) * logn)_   | _O(n)_        | Hard         | | Heap, Sort, Two Pointers, RMQ, Sparse Table, Segment Tree
3781 | [Maximum Score After Binary Swaps](https://leetcode.com/problems/maximum-score-after-binary-swaps/) | [C++](./C++/maximum-score-after-binary-swaps.cpp) [Python](./Python/maximum-score-after-binary-swaps.py) | _O(nlogn)_   | _O(n)_        | Medium         | | Heap
3962 | [Maximum Subarray Sum After at Most K Swaps](https://leetcode.com/problems/maximum-subarray-sum-after-at-most-k-swaps/) | [C++](./C++/maximum-subarray-sum-after-at-most-k-swaps.cpp) [Python](./Python/maximum-subarray-sum-after-at-most-k-swaps.py) | _O(n^2 * logk)_   | _O(n)_        | Hard         | | Prefix Sum, Heap, DP
4004 | [Minimum Moves to Balance Circular Array II](https://leetcode.com/problems/minimum-moves-to-balance-circular-array-ii/) | [C++](./C++/minimum-moves-to-balance-circular-array-ii.cpp) [Python](./Python/minimum-moves-to-balance-circular-array-ii.py) | _O(n^2 * logn)_   | _O(n)_        | Hard         | 🔒, variant of [Codeforces Round #13 C](https://codeforces.com/contest/13/problem/C) | L1 Isotonic Regression, Heap, Greedy, Graph,  Min-Cost Max-Flow, MCMF, Successive Shortest Path, SSP, `Dijkstra's Algorithm`, `Johnson Potential`



    **[⬆️ Back to Top](#algorithms)**



## Tree
|  #  | Title           |  Solution       |  Time           | Space           | Difficulty    | Tag          | Note| 
|-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------|-----|
3109 | [Find the Index of Permutation](https://leetcode.com/problems/find-the-index-of-permutation/)| [C++](./C++/find-the-index-of-permutation.cpp) [Python](./Python/find-the-index-of-permutation.py)| _O(nlogn)_ | _O(n)_ | Medium | 🔒, variant of [Count of Smaller Numbers After Self](https://leetcode.com/problems/count-of-smaller-numbers-after-self/) | BIT, Fenwick Tree, Combinatorics |
3515 | [Shortest Path in a Weighted Tree](https://leetcode.com/problems/shortest-path-in-a-weighted-tree/)| [C++](./C++/shortest-path-in-a-weighted-tree.cpp) [Python](./Python/shortest-path-in-a-weighted-tree.py)| _O(nlogn)_ | _O(n)_ | Hard |  | BIT, Fenwick Tree, DFS |
3553 | [Minimum Weighted Subgraph With the Required Paths II](https://leetcode.com/problems/minimum-weighted-subgraph-with-the-required-paths-ii/)| [C++](./C++/minimum-weighted-subgraph-with-the-required-paths-ii.cpp) [Python](./Python/minimum-weighted-subgraph-with-the-required-paths-ii.py)| _O(n + q)_ | _O(n + q)_ | Hard | | Tree, DFS, `Tarjan's Offline LCA Algorithm` |
3558 | [Number of Ways to Assign Edge Weights I](https://leetcode.com/problems/number-of-ways-to-assign-edge-weights-i/)| [C++](./C++/number-of-ways-to-assign-edge-weights-i.cpp) [Python](./Python/number-of-ways-to-assign-edge-weights-i.py)| _O(n)_ | _O(n)_ | Medium | | Tree, BFS, Combinatorics |
3559 | [Number of Ways to Assign Edge Weights II](https://leetcode.com/problems/number-of-ways-to-assign-edge-weights-ii/)| [C++](./C++/number-of-ways-to-assign-edge-weights-ii.cpp) [Python](./Python/number-of-ways-to-assign-edge-weights-ii.py)| _O(n + q)_ | _O(n + q)_ | Medium | | Tree, DFS, `Tarjan's Offline LCA Algorithm`, Combinatorics |
3585 | [Find Weighted Median Node in Tree](https://leetcode.com/problems/find-weighted-median-node-in-tree/)| [C++](./C++/find-weighted-median-node-in-tree.cpp) [Python](./Python/find-weighted-median-node-in-tree.py)| _O(n + qlogh)_ | _O(n + q)_ | Hard | | Tree, DFS, `Tarjan's Offline LCA Algorithm`, Binary Search, Prefix Sum |
3715 | [Sum of Perfect Square Ancestors](https://leetcode.com/problems/sum-of-perfect-square-ancestors/)| [C++](./C++/sum-of-perfect-square-ancestors.cpp) [Python](./Python/sum-of-perfect-square-ancestors.py)| 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](https://leetcode.com/problems/palindromic-path-queries-in-a-tree/)| [C++](./C++/palindromic-path-queries-in-a-tree.cpp) [Python](./Python/palindromic-path-queries-in-a-tree.py)| _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](https://leetcode.com/problems/maximum-distinct-path-sum-in-a-binary-tree/)| [C++](./C++/maximum-distinct-path-sum-in-a-binary-tree.cpp) [Python](./Python/maximum-distinct-path-sum-in-a-binary-tree.py)| _O(n^2)_ | _O(n)_ | Medium | | DFS, BFS
3973 | [Distinct Gate Paths to LCA](https://leetcode.com/problems/distinct-gate-paths-to-lca/)| [C++](./C++/distinct-gate-paths-to-lca.cpp) [Python](./Python/distinct-gate-paths-to-lca.py)| _O(nlogn + qlogn)_ | _O(nlogn)_ | Hard | 🔒 | DFS, LCA, Binary Lifting
3997 | [Count Dominant Nodes in a Binary Tree](https://leetcode.com/problems/count-dominant-nodes-in-a-binary-tree/)| [C++](./C++/count-dominant-nodes-in-a-binary-tree.cpp) [Python](./Python/count-dominant-nodes-in-a-binary-tree.py)| _O(n)_ | _O(h)_ | Medium | | DFS



    **[⬆️ Back to Top](#algorithms)**



## Hash Table
|  #  | Title           |  Solution       |  Time           | Space           | Difficulty    | Tag          | Note| 
|-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------|-----|
3005 | [Count Elements With Maximum Frequency](https://leetcode.com/problems/count-elements-with-maximum-frequency/) | [C++](./C++/count-elements-with-maximum-frequency.cpp) [Python](./Python/count-elements-with-maximum-frequency.py) | _O(n)_ | _O(n)_ | Easy || Freq Table
3039 | [Apply Operations to Make String Empty](https://leetcode.com/problems/apply-operations-to-make-string-empty/) | [C++](./C++/apply-operations-to-make-string-empty.cpp) [Python](./Python/apply-operations-to-make-string-empty.py) | _O(n)_ | _O(1)_ | Medium || Freq Table
3044 | [Most Frequent Prime](https://leetcode.com/problems/most-frequent-prime/) | [C++](./C++/most-frequent-prime.cpp) [Python](./Python/most-frequent-prime.py) | 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](https://leetcode.com/problems/split-the-array/) | [C++](./C++/split-the-array.cpp) [Python](./Python/split-the-array.py) | _O(n)_  | _O(n)_ | Easy || Freq Table
3078 | [Match Alphanumerical Pattern in Matrix I](https://leetcode.com/problems/match-alphanumerical-pattern-in-matrix-i/) | [C++](./C++/match-alphanumerical-pattern-in-matrix-i.cpp) [Python](./Python/match-alphanumerical-pattern-in-matrix-i.py) | _O(n * m * r * c)_  | _O(1)_ | Medium |🔒| Brute Force, Hash Table
3083 | [Existence of a Substring in a String and Its Reverse](https://leetcode.com/problems/existence-of-a-substring-in-a-string-and-its-reverse/) | [C++](./C++/existence-of-a-substring-in-a-string-and-its-reverse.cpp) [Python](./Python/existence-of-a-substring-in-a-string-and-its-reverse.py) | _O(n)_  | _O(min(n, 26^2))_ | Easy || Hash Table
3120 | [Count the Number of Special Characters I](https://leetcode.com/problems/count-the-number-of-special-characters-i/) | [C++](./C++/count-the-number-of-special-characters-i.cpp) [Python](./Python/count-the-number-of-special-characters-i.py) | _O(n + 26)_  | _O(26)_ | Easy || Hash Table
3121 | [Count the Number of Special Characters II](https://leetcode.com/problems/count-the-number-of-special-characters-ii/) | [C++](./C++/count-the-number-of-special-characters-ii.cpp) [Python](./Python/count-the-number-of-special-characters-ii.py) | _O(n + 26)_  | _O(26)_ | Medium || Hash Table
3137 | [Minimum Number of Operations to Make Word K-Periodic](https://leetcode.com/problems/minimum-number-of-operations-to-make-word-k-periodic/) | [C++](./C++/minimum-number-of-operations-to-make-word-k-periodic.cpp) [Python](./Python/minimum-number-of-operations-to-make-word-k-periodic.py) | _O(n)_  | _O(n)_ | Medium || Freq Table
3138 | [Minimum Length of Anagram Concatenation](https://leetcode.com/problems/minimum-length-of-anagram-concatenation/) | [C++](./C++/minimum-length-of-anagram-concatenation.cpp) [Python](./Python/minimum-length-of-anagram-concatenation.py) | _O(sqrt(n) * n + 26 * nlogn)_  | _O(26)_ | Medium || Number Theory, Freq Table
3143 | [Maximum Points Inside the Square](https://leetcode.com/problems/maximum-points-inside-the-square/) | [C++](./C++/maximum-points-inside-the-square.cpp) [Python](./Python/maximum-points-inside-the-square.py) | _O(n + 26)_  | _O(26)_ | Medium || Hash Table
3146 | [Permutation Difference between Two Strings](https://leetcode.com/problems/permutation-difference-between-two-strings/) | [C++](./C++/permutation-difference-between-two-strings.cpp) [Python](./Python/permutation-difference-between-two-strings.py) | _O(n + 26)_  | _O(26)_ | Easy || Hash Table
3158 | [Find the XOR of Numbers Which Appear Twice](https://leetcode.com/problems/find-the-xor-of-numbers-which-appear-twice/) | [C++](./C++/find-the-xor-of-numbers-which-appear-twice.cpp) [Python](./Python/find-the-xor-of-numbers-which-appear-twice.py) | _O(n)_  | _O(n)_ | Easy || Hash Table
3160 | [Find the Number of Distinct Colors Among the Balls](https://leetcode.com/problems/find-the-number-of-distinct-colors-among-the-balls/) | [C++](./C++/find-the-number-of-distinct-colors-among-the-balls.cpp) [Python](./Python/find-the-number-of-distinct-colors-among-the-balls.py) | _O(q)_  | _O(q)_ | Medium || Freq Table
3167 | [Better Compression of String](https://leetcode.com/problems/better-compression-of-string/) | [C++](./C++/better-compression-of-string.cpp) [Python](./Python/better-compression-of-string.py) | _O(n + 26)_  | _O(26)_ | Medium | 🔒 | Freq Table, Counting Sort
3184 | [Count Pairs That Form a Complete Day I](https://leetcode.com/problems/count-pairs-that-form-a-complete-day-i/) | [C++](./C++/count-pairs-that-form-a-complete-day-i.cpp) [Python](./Python/count-pairs-that-form-a-complete-day-i.py) | _O(n + 24)_  | _O(24)_ | Easy | | Freq Table
3185 | [Count Pairs That Form a Complete Day II](https://leetcode.com/problems/count-pairs-that-form-a-complete-day-ii/) | [C++](./C++/count-pairs-that-form-a-complete-day-ii.cpp) [Python](./Python/count-pairs-that-form-a-complete-day-ii.py) | _O(n + 24)_  | _O(24)_ | Medium | | Freq Table
3223 | [Minimum Length of String After Operations](https://leetcode.com/problems/minimum-length-of-string-after-operations/) | [C++](./C++/minimum-length-of-string-after-operations.cpp) [Python](./Python/minimum-length-of-string-after-operations.py) | _O(n + 26)_  | _O(26)_ | Medium | | Freq Table
3237 | [Alt and Tab Simulation](https://leetcode.com/problems/alt-and-tab-simulation/) | [C++](./C++/alt-and-tab-simulation.cpp) [Python](./Python/alt-and-tab-simulation.py) | _O(n)_  | _O(n)_ | Medium | 🔒 | Hash Table
3238 | [Find the Number of Winning Players](https://leetcode.com/problems/find-the-number-of-winning-players/) | [C++](./C++/find-the-number-of-winning-players.cpp) [Python](./Python/find-the-number-of-winning-players.py) | _O(p)_  | _O(min(n * c, p)_ | Easy | | Freq Table
3245 | [Alternating Groups III](https://leetcode.com/problems/alternating-groups-iii/) | [C++](./C++/alternating-groups-iii.cpp) [Python](./Python/alternating-groups-iii.py) | _O(nlogn + qlogn)_ | _O(n)_ | Hard | | BST, Sorted List, Freq Table, BIT, Fenwick Tree
3295 | [Report Spam Message](https://leetcode.com/problems/report-spam-message/) | [C++](./C++/report-spam-message.cpp) [Python](./Python/report-spam-message.py) | _O(n + m)_ | _O(m)_ | Medium | | Hash Table
3365 | [Rearrange K Substrings to Form Target String](https://leetcode.com/problems/rearrange-k-substrings-to-form-target-string/) | [C++](./C++/rearrange-k-substrings-to-form-target-string.cpp) [Python](./Python/rearrange-k-substrings-to-form-target-string.py) | _O(n)_ | _O(n)_ | Medium | | Freq Table
3371 | [Identify the Largest Outlier in an Array](https://leetcode.com/problems/identify-the-largest-outlier-in-an-array/) | [C++](./C++/identify-the-largest-outlier-in-an-array.cpp) [Python](./Python/identify-the-largest-outlier-in-an-array.py) | _O(n)_ | _O(n)_ | Medium | | Freq Table
3396 | [Minimum Number of Operations to Make Elements in Array Distinct](https://leetcode.com/problems/minimum-number-of-operations-to-make-elements-in-array-distinct/) | [C++](./C++/minimum-number-of-operations-to-make-elements-in-array-distinct.cpp) [Python](./Python/minimum-number-of-operations-to-make-elements-in-array-distinct.py) | _O(n + r)_ | _O(r)_ | Easy | | Freq Table
3404 | [Count Special Subsequences](https://leetcode.com/problems/count-special-subsequences/) | [C++](./C++/count-special-subsequences.cpp) [Python](./Python/count-special-subsequences.py) | _O(n^2)_ | _O(n^2)_ | Medium | | Freq Table, Number Theory
3438 | [Find Valid Pair of Adjacent Digits in String](https://leetcode.com/problems/find-valid-pair-of-adjacent-digits-in-string/) | [C++](./C++/find-valid-pair-of-adjacent-digits-in-string.cpp) [Python](./Python/find-valid-pair-of-adjacent-digits-in-string.py) | _O(n)_ | _O(1)_ | Easy | | Freq Table
3442 | [Maximum Difference Between Even and Odd Frequency I](https://leetcode.com/problems/maximum-difference-between-even-and-odd-frequency-i/) | [C++](./C++/maximum-difference-between-even-and-odd-frequency-i.cpp) [Python](./Python/maximum-difference-between-even-and-odd-frequency-i.py) | _O(n + 26)_ | _O(26)_ | Easy | | Freq Table
3450 | [Maximum Students on a Single Bench](https://leetcode.com/problems/maximum-students-on-a-single-bench/) | [C++](./C++/maximum-students-on-a-single-bench.cpp) [Python](./Python/maximum-students-on-a-single-bench.py) | _O(n)_ | _O(n)_ | Easy | 🔒 | Hash Table, Unordered Set
3471 | [Find the Largest Almost Missing Integer](https://leetcode.com/problems/find-the-largest-almost-missing-integer/) | [C++](./C++/find-the-largest-almost-missing-integer.cpp) [Python](./Python/find-the-largest-almost-missing-integer.py) | _O(n)_ | _O(n)_ | Easy | | Freq Table
3487 | [Maximum Unique Subarray Sum After Deletion](https://leetcode.com/problems/maximum-unique-subarray-sum-after-deletion/) | [C++](./C++/maximum-unique-subarray-sum-after-deletion.cpp) [Python](./Python/maximum-unique-subarray-sum-after-deletion.py) | _O(n)_ | _O(n)_ | Easy | | Hash Table
3488 | [Closest Equal Element Queries](https://leetcode.com/problems/closest-equal-element-queries/) | [C++](./C++/closest-equal-element-queries.cpp) [Python](./Python/closest-equal-element-queries.py) | _O(n)_ | _O(n)_ | Medium | | Hash Table
3527 | [Find the Most Common Response](https://leetcode.com/problems/find-the-most-common-response/) | [C++](./C++/find-the-most-common-response.cpp) [Python](./Python/find-the-most-common-response.py) | _O(n * l)_ | _O(n * l)_ | Medium | | Hash Table, Freq Table
3541 | [Find Most Frequent Vowel and Consonant](https://leetcode.com/problems/find-most-frequent-vowel-and-consonant/) | [C++](./C++/find-most-frequent-vowel-and-consonant.cpp) [Python](./Python/find-most-frequent-vowel-and-consonant.py) | _O(n + 26)_ | _O(26)_ | Easy | | Freq Table
3572 | [Maximize Y‑Sum by Picking a Triplet of Distinct X‑Values](https://leetcode.com/problems/maximize-ysum-by-picking-a-triplet-of-distinct-xvalues/) | [C++](./C++/maximize-ysum-by-picking-a-triplet-of-distinct-xvalues.cpp) [Python](./Python/maximize-ysum-by-picking-a-triplet-of-distinct-xvalues.py) | _O(n)_ | _O(n)_ | Medium | | Hash Table, Quick Select
3581 | [Count Odd Letters from Number](https://leetcode.com/problems/count-odd-letters-from-number/) | [C++](./C++/count-odd-letters-from-number.cpp) [Python](./Python/count-odd-letters-from-number.py) | _O(logn)_ | _O(26)_ | Easy |🔒| Freq Table
3591 | [Check if Any Element Has Prime Frequency](https://leetcode.com/problems/check-if-any-element-has-prime-frequency/) | [C++](./C++/check-if-any-element-has-prime-frequency.cpp) [Python](./Python/check-if-any-element-has-prime-frequency.py) | precompute: _O(MAX_N)_runtime: _O(n)_ | _O(MAX_N)_ | Easy || Freq Table, Number Theory, `Linear Sieve of Eratosthenes`
3636 | [Threshold Majority Queries](https://leetcode.com/problems/threshold-majority-queries/) | [C++](./C++/threshold-majority-queries.cpp) [Python](./Python/threshold-majority-queries.py) | _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](https://leetcode.com/problems/filter-characters-by-frequency/) | [C++](./C++/filter-characters-by-frequency.cpp) [Python](./Python/filter-characters-by-frequency.py) | _O(n + 26)_ | _O(26)_ | Easy |🔒| Freq Table
3663 | [Find The Least Frequent Digit](https://leetcode.com/problems/find-the-least-frequent-digit/) | [C++](./C++/find-the-least-frequent-digit.cpp) [Python](./Python/find-the-least-frequent-digit.py) | _O(logn + 10)_ | _O(10)_ | Easy | | Freq Table
3668 | [Restore Finishing Order](https://leetcode.com/problems/restore-finishing-order/) | [C++](./C++/restore-finishing-order.cpp) [Python](./Python/restore-finishing-order.py) | _O(n + min(8, n))_ | _O(min(8, n))_ | Easy | | Hash Table
3678 | [Smallest Absent Positive Greater Than Average](https://leetcode.com/problems/smallest-absent-positive-greater-than-average/) | [C++](./C++/smallest-absent-positive-greater-than-average.cpp) [Python](./Python/smallest-absent-positive-greater-than-average.py) | _O(n)_ | _O(n)_ | Easy | | Hash Table
3682 | [Minimum Index Sum of Common Elements](https://leetcode.com/problems/minimum-index-sum-of-common-elements/) | [C++](./C++/minimum-index-sum-of-common-elements.cpp) [Python](./Python/minimum-index-sum-of-common-elements.py) | _O(n + m)_ | _O(n)_ | Medium | 🔒 | Hash Table
3692 | [Majority Frequency Characters](https://leetcode.com/problems/majority-frequency-characters/) | [C++](./C++/majority-frequency-characters.cpp) [Python](./Python/majority-frequency-characters.py) | _O(n + 26)_ | _O(26)_ | Easy | | Freq Table
3694 | [Distinct Points Reachable After Substring Removal](https://leetcode.com/problems/distinct-points-reachable-after-substring-removal/) | [C++](./C++/distinct-points-reachable-after-substring-removal.cpp) [Python](./Python/distinct-points-reachable-after-substring-removal.py) | _O(n)_ | _O(n)_ | Medium | | Hash Table
3712 | [Sum of Elements With Frequency Divisible by K](https://leetcode.com/problems/sum-of-elements-with-frequency-divisible-by-k/) | [C++](./C++/sum-of-elements-with-frequency-divisible-by-k.cpp) [Python](./Python/sum-of-elements-with-frequency-divisible-by-k.py) | _O(n)_ | _O(n)_ | Easy | | Freq Table
3713 | [Longest Balanced Substring I](https://leetcode.com/problems/longest-balanced-substring-i/) | [C++](./C++/longest-balanced-substring-i.cpp) [Python](./Python/longest-balanced-substring-i.py) | _O(n * (a + n))_ | _O(a)_ | Medium | | Freq Table
3714 | [Longest Balanced Substring II](https://leetcode.com/problems/longest-balanced-substring-ii/) | [C++](./C++/longest-balanced-substring-ii.cpp) [Python](./Python/longest-balanced-substring-ii.py) | _O(n)_ | _O(n)_ | Medium | | Hash Table, Prefix Sum
3718 | [Smallest Missing Multiple of K](https://leetcode.com/problems/smallest-missing-multiple-of-k/) | [C++](./C++/smallest-missing-multiple-of-k.cpp) [Python](./Python/smallest-missing-multiple-of-k.py) | _O(n)_ | _O(n)_ | Easy | | Hash Table
3728 | [Stable Subarrays With Equal Boundary and Interior Sum](https://leetcode.com/problems/stable-subarrays-with-equal-boundary-and-interior-sum/) | [C++](./C++/stable-subarrays-with-equal-boundary-and-interior-sum.cpp) [Python](./Python/stable-subarrays-with-equal-boundary-and-interior-sum.py) | _O(n)_ | _O(n)_ | Medium | | Freq Table, Prefix Sum
3729 | [Count Distinct Subarrays Divisible by K in Sorted Array](https://leetcode.com/problems/count-distinct-subarrays-divisible-by-k-in-sorted-array/) | [C++](./C++/count-distinct-subarrays-divisible-by-k-in-sorted-array.cpp) [Python](./Python/count-distinct-subarrays-divisible-by-k-in-sorted-array.py) | _O(n)_ | _O(min(n, k))_ | Hard | | Freq Table, Prefix Sum
3755 | [Find Maximum Balanced XOR Subarray Length](https://leetcode.com/problems/find-maximum-balanced-xor-subarray-length/) | [C++](./C++//find-maximum-balanced-xor-subarray-length.cpp) [Python](./Python/find-maximum-balanced-xor-subarray-length.py) | _O(n)_ | _O(n)_ | Medium | | Hash Table, Prefix Sum
3760 | [Maximum Substrings With Distinct Start](https://leetcode.com/problems/maximum-substrings-with-distinct-start/) | [C++](./C++/maximum-substrings-with-distinct-start.cpp) [Python](./Python/maximum-substrings-with-distinct-start.py) | _O(n + 26)_ | _O(26)_ | Medium | | Hash Table
3761 | [Minimum Absolute Distance Between Mirror Pairs](https://leetcode.com/problems/minimum-absolute-distance-between-mirror-pairs/) | [C++](./C++/minimum-absolute-distance-between-mirror-pairs.cpp) [Python](./Python/minimum-absolute-distance-between-mirror-pairs.py) | _O(nlogr)_ | _O(n)_ | Medium | | Hash Table
3773 | [Maximum Number of Equal Length Runs](https://leetcode.com/problems/maximum-number-of-equal-length-runs/) | [C++](./C++/maximum-number-of-equal-length-runs.cpp) [Python](./Python/maximum-number-of-equal-length-runs.py) | _O(n)_ | _O(sqrt(n))_ | Medium | 🔒 | Freq Table
3779 | [Minimum Number of Operations to Have Distinct Elements](https://leetcode.com/problems/minimum-number-of-operations-to-have-distinct-elements/) | [C++](./C++/minimum-number-of-operations-to-have-distinct-elements.cpp) [Python](./Python/minimum-number-of-operations-to-have-distinct-elements.py) | _O(n)_ | _O(n)_ | Medium | | Hash Table
3784 | [Minimum Deletion Cost to Make All Characters Equal](https://leetcode.com/problems/minimum-deletion-cost-to-make-all-characters-equal/) | [C++](./C++/minimum-deletion-cost-to-make-all-characters-equal.cpp) [Python](./Python/minimum-deletion-cost-to-make-all-characters-equal.py) | _O(n + 26)_ | _O(26)_ | Medium | | Freq Table
3803 | [Count Residue Prefixes](https://leetcode.com/problems/count-residue-prefixes/) | [C++](./C++/count-residue-prefixes.cpp) [Python](./Python/count-residue-prefixes.py) | _O(n + 26)_ | _O(26)_ | Easy | | Hash Table
3804 | [Number of Centered Subarrays](https://leetcode.com/problems/number-of-centered-subarrays/) | [C++](./C++/number-of-centered-subarrays.cpp) [Python](./Python/number-of-centered-subarrays.py) | _O(n^2)_ | _O(n)_ | Medium | | Hash Table
3805 | [Count Caesar Cipher Pairs](https://leetcode.com/problems/count-caesar-cipher-pairs/) | [C++](./C++/count-caesar-cipher-pairs.cpp) [Python](./Python/count-caesar-cipher-pairs.py) | _O(n * m)_ | _O(n * m)_ | Medium | | Freq Table
3810 | [Minimum Operations to Reach Target Array](https://leetcode.com/problems/minimum-operations-to-reach-target-array/) | [C++](./C++/minimum-operations-to-reach-target-array.cpp) [Python](./Python/minimum-operations-to-reach-target-array.py) | _O(n)_ | _O(n)_ | Medium | | Hash Table
3837 | [Delayed Count of Equal Elements](https://leetcode.com/problems/delayed-count-of-equal-elements/) | [C++](./C++/delayed-count-of-equal-elements.cpp) [Python](./Python/delayed-count-of-equal-elements.py) | _O(n)_ | _O(n)_ | Medium | 🔒 | Freq Table
3839 | [Number of Prefix Connected Groups](https://leetcode.com/problems/number-of-prefix-connected-groups/) | [C++](./C++/number-of-prefix-connected-groups.cpp) [Python](./Python/number-of-prefix-connected-groups.py) | _O(n * k)_ | _O(n * k)_ | Medium | | Freq Table
3842 | [Toggle Light Bulbs](https://leetcode.com/problems/toggle-light-bulbs/) | [C++](./C++/toggle-light-bulbs.cpp) [Python](./Python/toggle-light-bulbs.py) | _O(n + r)_ | _O(r)_ | Easy | | Freq Table, Sort
3843 | [First Element with Unique Frequency](https://leetcode.com/problems/first-element-with-unique-frequency/) | [C++](./C++/first-element-with-unique-frequency.cpp) [Python](./Python/first-element-with-unique-frequency.py) | _O(n)_ | _O(n)_ | Medium | | Freq Table
3846 | [Total Distance to Type a String Using One Finger](https://leetcode.com/problems/total-distance-to-type-a-string-using-one-finger/) | [C++](./C++/total-distance-to-type-a-string-using-one-finger.cpp) [Python](./Python/total-distance-to-type-a-string-using-one-finger.py) | _O(n)_ | _O(n)_ | Medium | 🔒 | Hash Table
3848 | [Check Digitorial Permutation](https://leetcode.com/problems/check-digitorial-permutation/) | [C++](./C++/check-digitorial-permutation.cpp) [Python](./Python/check-digitorial-permutation.py) | _O(logn + 10)_ | _O(10)_ | Medium | | Freq Table
3852 | [Smallest Pair With Different Frequencies](https://leetcode.com/problems/smallest-pair-with-different-frequencies/) | [C++](./C++/smallest-pair-with-different-frequencies.cpp) [Python](./Python/smallest-pair-with-different-frequencies.py) | _O(n)_ | _O(n)_ | Easy | | Freq Table
3866 | [First Unique Even Element](https://leetcode.com/problems/first-unique-even-element/) | [C++](./C++/first-unique-even-element.cpp) [Python](./Python/first-unique-even-element.py) | _O(n)_ | _O(n)_ | Easy | | Freq Table
3889 | [Mirror Frequency Distance](https://leetcode.com/problems/mirror-frequency-distance/) | [C++](./C++/mirror-frequency-distance.cpp) [Python](./Python/mirror-frequency-distance.py) | _O(n + 36)_ | _O(36)_ | Medium| | Freq Table
3890 | [Integers With Multiple Sum of Two Cubes](https://leetcode.com/problems/integers-with-multiple-sum-of-two-cubes/) | [C++](./C++/integers-with-multiple-sum-of-two-cubes.cpp) [Python](./Python/integers-with-multiple-sum-of-two-cubes.py) | _O(n^(2/3) * logn)_ | _O(n^(2/3))_ | Medium| | Brute Force, Freq Table, Sort
3900 | [Longest Balanced Substring After One Swap](https://leetcode.com/problems/longest-balanced-substring-after-one-swap/) |[C++](./C++/longest-balanced-substring-after-one-swap.cpp)  [Python](./Python/longest-balanced-substring-after-one-swap.py) | _O(n)_ | _O(n)_ | Medium         | variant of [Contiguous Array](https://leetcode.com/problems/contiguous-array/) | Hash Table
3901 | [Good Subsequence Queries](https://leetcode.com/problems/good-subsequence-queries/) |[C++](./C++/good-subsequence-queries.cpp)  [Python](./Python/good-subsequence-queries.py) | precompute: _O(rlog(logr))_runtime: _O(r + n + q)_ | _O(rlog(logr) + n)_ | Medium         |  | Number Theory, Freq Table
3913 | [Sort Vowels by Frequency](https://leetcode.com/problems/sort-vowels-by-frequency/) |[C++](./C++/sort-vowels-by-frequency.cpp)  [Python](./Python/sort-vowels-by-frequency.py) | _O(n)_ | _O(1)_ | Medium         | | Freq Table, Sort
3917 | [Count Indices With Opposite Parity](https://leetcode.com/problems/count-indices-with-opposite-parity/) |[C++](./C++/count-indices-with-opposite-parity.cpp)  [Python](./Python/count-indices-with-opposite-parity.py) | _O(n)_ | _O(1)_ | Easy         | | Freq Table
3921 | [Score Validator](https://leetcode.com/problems/score-validator/) |[C++](./C++/score-validator.cpp)  [Python](./Python/score-validator.py) | _O(n)_ | _O(1)_ | Easy         | | Freq Table
3926 | [Count Valid Word Occurrences](https://leetcode.com/problems/count-valid-word-occurrences/) |[C++](./C++/count-valid-word-occurrences.cpp)  [Python](./Python/count-valid-word-occurrences.py) | _O(n)_ | _O(n)_ | Medium         | | Freq Table
3945 | [Digit Frequency Score](https://leetcode.com/problems/digit-frequency-score/) |[C++](./C++/digit-frequency-score.cpp)  [Python](./Python/digit-frequency-score.py) | _O(logn)_ | _O(1)_ | Easy         | | Freq Table
3960 | [Frequency Balance Subarray](https://leetcode.com/problems/frequency-balance-subarray/) |[C++](./C++/frequency-balance-subarray.cpp)  [Python](./Python/frequency-balance-subarray.py) | _O(n^2)_ | _O(n)_ | Medium         | | Sort, Coordinate Compression, Freq Table
4007 | [Widest Possible Fence](https://leetcode.com/problems/widest-possible-fence/) |[C++](./C++/widest-possible-fence.cpp)  [Python](./Python/widest-possible-fence.py) | _O(n + c^2)_ | _O(c^2)_ | Medium         | | Freq Table



    **[⬆️ Back to Top](#algorithms)**



## Math
|  #  | Title           |  Solution       |  Time           | Space           | Difficulty    | Tag          | Note| 
|-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------|-----|
3001 | [Minimum Moves to Capture The Queen](https://leetcode.com/problems/minimum-moves-to-capture-the-queen/) | [C++](./C++/minimum-moves-to-capture-the-queen.cpp) [Python](./Python/minimum-moves-to-capture-the-queen.py) | _O(1)_ | _O(1)_ | Medium || Math |
3007 | [Maximum Number That Sum of the Prices Is Less Than or Equal to K](https://leetcode.com/problems/maximum-number-that-sum-of-the-prices-is-less-than-or-equal-to-k/) | [C++](./C++/maximum-number-that-sum-of-the-prices-is-less-than-or-equal-to-k.cpp) [Python](./Python/maximum-number-that-sum-of-the-prices-is-less-than-or-equal-to-k.py) | _O(max(logk, x) * log((logk) / x))_ | _O((logk) / x)_ | Medium || Bit Manipulation, Binary Search, Combinatorics |
3021 | [Alice and Bob Playing Flower Game](https://leetcode.com/problems/alice-and-bob-playing-flower-game/) | [C++](./C++/alice-and-bob-playing-flower-game.cpp) [Python](./Python/alice-and-bob-playing-flower-game.py) | _O(1)_ | _O(1)_ | Medium || Combinatorics |
3024 | [Type of Triangle II](https://leetcode.com/problems/type-of-triangle-ii/) | [C++](./C++/type-of-triangle-ii.cpp) [Python](./Python/type-of-triangle-ii.py) | _O(1)_ | _O(1)_ | Easy || Math |
3032 | [Count Numbers With Unique Digits II](https://leetcode.com/problems/count-numbers-with-unique-digits-ii/) | [C++](./C++/count-numbers-with-unique-digits-ii.cpp) [Python](./Python/count-numbers-with-unique-digits-ii.py) | _O(logb)_ | _O(1)_ | Easy |🔒, variant of [Count Numbers With Unique Digits](https://leetcode.com/problems/count-numbers-with-unique-digits/) | Brute Force, Hash Table, Bitmasks, Combinatorics
3047 | [Find the Largest Area of Square Inside Two Rectangles](https://leetcode.com/problems/find-the-largest-area-of-square-inside-two-rectangles/) | [C++](./C++/find-the-largest-area-of-square-inside-two-rectangles.cpp) [Python](./Python/find-the-largest-area-of-square-inside-two-rectangles.py) | _O(n^2)_ | _O(1)_ | Meidum || Brute Force, Math |
3084 | [Count Substrings Starting and Ending with Given Character](https://leetcode.com/problems/count-substrings-starting-and-ending-with-given-character/) | [C++](./C++/count-substrings-starting-and-ending-with-given-character.cpp) [Python](./Python/count-substrings-starting-and-ending-with-given-character.py) | _O(n)_ | _O(1)_ | Meidum || Combinatorics |
3091 | [Apply Operations to Make Sum of Array Greater Than or Equal to k](https://leetcode.com/problems/apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k/) | [C++](./C++/apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k.cpp) [Python](./Python/apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k.py) | _O(logn)_ | _O(1)_ | Meidum | [Codeforces Round #674 C](https://codeforces.com/contest/1426/problem/C) | Math |
3099 | [Harshad Number](https://leetcode.com/problems/harshad-number/) | [C++](./C++/harshad-number.cpp) [Python](./Python/harshad-number.py) | _O(logx)_ | _O(1)_ | Easy | | Math |
3102 | [Minimize Manhattan Distances](https://leetcode.com/problems/minimize-manhattan-distances/) | [C++](./C++/minimize-manhattan-distances.cpp) [Python](./Python/minimize-manhattan-distances.py) | _O(n)_ | _O(1)_ | Hard | | Math |
3115 | [Maximum Prime Difference](https://leetcode.com/problems/maximum-prime-difference/) | [C++](./C++/maximum-prime-difference.cpp) [Python](./Python/maximum-prime-difference.py) | _O(r + n)_ | _O(r)_ | Medium | | Array, Number Theory, `Linear Sieve of Eratosthenes` |
3128 | [Right Triangles](https://leetcode.com/problems/right-triangles/) | [C++](./C++/right-triangles.cpp) [Python](./Python/right-triangles.py) | _O(n * m)_ | _O(min(n, m))_ | Medium | | Array, Combinatorics, Freq Table |
3154 | [Find Number of Ways to Reach the K-th Stair](https://leetcode.com/problems/find-number-of-ways-to-reach-the-k-th-stair/) | [C++](./C++/find-number-of-ways-to-reach-the-k-th-stair.cpp) [Python](./Python/find-number-of-ways-to-reach-the-k-th-stair.py) | _O(logk)_ | _O(logk)_ | Hard | | Combinatorics |
3155 | [Maximum Number of Upgradable Servers](https://leetcode.com/problems/maximum-number-of-upgradable-servers/) | [C++](./C++/maximum-number-of-upgradable-servers.cpp) [Python](./Python/maximum-number-of-upgradable-servers.py) | _O(n)_ | _O(1)_ | Medium | 🔒 | Math |
3162 | [Find the Number of Good Pairs I](https://leetcode.com/problems/find-the-number-of-good-pairs-i/) | [C++](./C++/find-the-number-of-good-pairs-i.cpp) [Python](./Python/find-the-number-of-good-pairs-i.py) | _O(rlogr + n + m)_ | _O(r)_ | Easy | | Brute Force, Number Theory, Freq Table |
3164 | [Find the Number of Good Pairs II](https://leetcode.com/problems/find-the-number-of-good-pairs-ii/) | [C++](./C++/find-the-number-of-good-pairs-ii.cpp) [Python](./Python/find-the-number-of-good-pairs-ii.py) | _O(rlogr + n + m)_ | _O(r)_ | Medium | | Number Theory, Freq Table |
3178 | [Find the Child Who Has the Ball After K Seconds](https://leetcode.com/problems/find-the-child-who-has-the-ball-after-k-seconds/) | [C++](./C++/find-the-child-who-has-the-ball-after-k-seconds.cpp) [Python](./Python/find-the-child-who-has-the-ball-after-k-seconds.py) | _O(1)_ | _O(1)_ | Easy | | Math |
3179 | [Find the N-th Value After K Seconds](https://leetcode.com/problems/find-the-n-th-value-after-k-seconds/) | [C++](./C++/find-the-n-th-value-after-k-seconds.cpp) [Python](./Python/find-the-n-th-value-after-k-seconds.py) | _O(n + k)_ | _O(n + k)_ | Medium | | Prefix Sum, Combinatorics |
3183 | [The Number of Ways to Make the Sum](https://leetcode.com/problems/the-number-of-ways-to-make-the-sum/) | [C++](./C++/the-number-of-ways-to-make-the-sum.cpp) [Python](./Python/the-number-of-ways-to-make-the-sum.py) | _O(1)_ | _O(1)_ | Medium | 🔒 | Math, DP |
3190 | [Find Minimum Operations to Make All Elements Divisible by Three](https://leetcode.com/problems/find-minimum-operations-to-make-all-elements-divisible-by-three/) | [C++](./C++/find-minimum-operations-to-make-all-elements-divisible-by-three.cpp) [Python](./Python/find-minimum-operations-to-make-all-elements-divisible-by-three.py) | _O(n)_ | _O(1)_ | Easy | | Math |
3200 | [Maximum Height of a Triangle](https://leetcode.com/problems/maximum-height-of-a-triangle/) | [C++](./C++/maximum-height-of-a-triangle.cpp) [Python](./Python/maximum-height-of-a-triangle.py) | _O(logn)_ | _O(1)_ | Easy | | Simulation, Math |
3222 | [Find the Winning Player in Coin Game](https://leetcode.com/problems/find-the-winning-player-in-coin-game/) | [C++](./C++/find-the-winning-player-in-coin-game.cpp) [Python](./Python/find-the-winning-player-in-coin-game.py) | _O(1)_ | _O(1)_ | Easy | | Math |
3227 | [Vowels Game in a String](https://leetcode.com/problems/vowels-game-in-a-string/) | [C++](./C++/vowels-game-in-a-string.cpp) [Python](./Python/vowels-game-in-a-string.py) | _O(n)_ | _O(1)_ | Medium | | Math |
3232 | [Find if Digit Game Can Be Won](https://leetcode.com/problems/find-if-digit-game-can-be-won/) | [C++](./C++/find-if-digit-game-can-be-won.cpp) [Python](./Python/find-if-digit-game-can-be-won.py) | _O(n)_ | _O(1)_ | Easy | | Brute Force, Game Theory |
3247 | [Number of Subsequences with Odd Sum](https://leetcode.com/problems/number-of-subsequences-with-odd-sum/) | [C++](./C++/number-of-subsequences-with-odd-sum.cpp) [Python](./Python/number-of-subsequences-with-odd-sum.py) | _O(n)_ | _O(1)_ | Medium | 🔒 | Combinatorics, Fast Exponentiation, DP |
3250 | [Find the Count of Monotonic Pairs I](https://leetcode.com/problems/find-the-count-of-monotonic-pairs-i/) | [C++](./C++/find-the-count-of-monotonic-pairs-i.cpp) [Python](./Python/find-the-count-of-monotonic-pairs-i.py) | _O(n + r)_ | _O(n + r)_ | Hard | | Combinatorics, Stars and Bars, DP, Prefix Sum |
3251 | [Find the Count of Monotonic Pairs II](https://leetcode.com/problems/find-the-count-of-monotonic-pairs-ii/) | [C++](./C++/find-the-count-of-monotonic-pairs-ii.cpp) [Python](./Python/find-the-count-of-monotonic-pairs-ii.py) | _O(n + r)_ | _O(n + r)_ | Hard | | Combinatorics, Stars and Bars, DP, Prefix Sum |
3270 | [Find the Key of the Numbers](https://leetcode.com/problems/find-the-key-of-the-numbers/) | [C++](./C++/find-the-key-of-the-numbers.cpp) [Python](./Python/find-the-key-of-the-numbers.py) | _O(d)_ | _O(1)_ | Easy | | Math |
3272 | [Find the Count of Good Integers](https://leetcode.com/problems/find-the-count-of-good-integers/) | [C++](./C++/find-the-count-of-good-integers.cpp) [Python](./Python/find-the-count-of-good-integers.py) | _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](https://leetcode.com/problems/check-if-two-chessboard-squares-have-the-same-color/) | [C++](./C++/check-if-two-chessboard-squares-have-the-same-color.cpp) [Python](./Python/check-if-two-chessboard-squares-have-the-same-color.py) | _O(1)_ | _O(1)_ | Easy | | Math, Parity |
3284 | [Sum of Consecutive Subarrays](https://leetcode.com/problems/sum-of-consecutive-subarrays/) | [C++](./C++/sum-of-consecutive-subarrays.cpp) [Python](./Python/sum-of-consecutive-subarrays.py) | _O(n)_ | _O(1)_ | Medium | 🔒 | Combinatorics |
3299 | [Sum of Consecutive Subsequences](https://leetcode.com/problems/sum-of-consecutive-subsequences/) | [C++](./C++/sum-of-consecutive-subsequences.cpp) [Python](./Python/sum-of-consecutive-subsequences.py) | _O(n)_ | _O(n)_ | Hard | 🔒 | Combinatorics, Prefix Sum, DP |
3312 | [Sorted GCD Pair Queries](https://leetcode.com/problems/sorted-gcd-pair-queries/) | [C++](./C++/sorted-gcd-pair-queries.cpp) [Python](./Python/sorted-gcd-pair-queries.py) | _O(rlogr + qlogr)_ | _O(r)_ | Hard | | Number Theory, Freq Table, Prefix Sum, Binary Search |
3317 | [Find the Number of Possible Ways for an Event](https://leetcode.com/problems/find-the-number-of-possible-ways-for-an-event/) | [C++](./C++/find-the-number-of-possible-ways-for-an-event.cpp) [Python](./Python/find-the-number-of-possible-ways-for-an-event.py) | 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](https://leetcode.com/problems/minimum-division-operations-to-make-array-non-decreasing/) | [C++](./C++/minimum-division-operations-to-make-array-non-decreasing.cpp) [Python](./Python/minimum-division-operations-to-make-array-non-decreasing.py) | precompute: _O(r)_runtime: _O(n)_ | _O(r)_ | Medium | | Greedy, Number Theory, `Linear Sieve of Eratosthenes` |
3339 | [Find the Number of K-Even Arrays](https://leetcode.com/problems/find-the-number-of-k-even-arrays/) | [C++](./C++/find-the-number-of-k-even-arrays.cpp) [Python](./Python/find-the-number-of-k-even-arrays.py) | _O(n)_ | _O(n)_ | Medium | 🔒 | DP, Stars and Bars, Combinatorics |
3345 | [Smallest Divisible Digit Product I](https://leetcode.com/problems/smallest-divisible-digit-product-i/) | [C++](./C++/smallest-divisible-digit-product-i.cpp) [Python](./Python/smallest-divisible-digit-product-i.py) | _O(logn)_ | _O(1)_ | Easy | | Brute Force |
3348 | [Smallest Divisible Digit Product II](https://leetcode.com/problems/smallest-divisible-digit-product-ii/) | [C++](./C++/smallest-divisible-digit-product-ii.cpp) [Python](./Python/smallest-divisible-digit-product-ii.py) | _O(n + logt)_ | _O(1)_ | Hard | | Freq Table, Greedy, Prefix Sum, Number Theory |
3360 | [Stone Removal Game](https://leetcode.com/problems/stone-removal-game/) | [C++](./C++/stone-removal-game.cpp) [Python](./Python/stone-removal-game.py) | _O(1)_ | _O(1)_ | Easy | | Math |
3395 | [Subsequences with a Unique Middle Mode I](https://leetcode.com/problems/subsequences-with-a-unique-middle-mode-i/) | [C++](./C++/subsequences-with-a-unique-middle-mode-i.cpp) [Python](./Python/subsequences-with-a-unique-middle-mode-i.py) | _O(n)_ | _O(n)_ | Hard | | Freq Table, Prefix Sum, Combinatorics |
3405 | [Count the Number of Arrays with K Matching Adjacent Elements](https://leetcode.com/problems/count-the-number-of-arrays-with-k-matching-adjacent-elements/) | [C++](./C++/count-the-number-of-arrays-with-k-matching-adjacent-elements.cpp) [Python](./Python/count-the-number-of-arrays-with-k-matching-adjacent-elements.py) | _O(n + logm)_ | _O(n)_ | Hard | | Combinatorics, Fast Exponentiation |
3411 | [Maximum Subarray With Equal Products](https://leetcode.com/problems/maximum-subarray-with-equal-products/) | [C++](./C++/maximum-subarray-with-equal-products.cpp) [Python](./Python/maximum-subarray-with-equal-products.py) | 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](https://leetcode.com/problems/subsequences-with-a-unique-middle-mode-ii/) | [C++](./C++/subsequences-with-a-unique-middle-mode-ii.cpp) [Python](./Python/subsequences-with-a-unique-middle-mode-ii.py) | _O(n)_ | _O(n)_ | Hard | 🔒 | Freq Table, Prefix Sum, Combinatorics |
3426 | [Manhattan Distances of All Arrangements of Pieces](https://leetcode.com/problems/manhattan-distances-of-all-arrangements-of-pieces/) | [C++](./C++/manhattan-distances-of-all-arrangements-of-pieces.cpp) [Python](./Python/manhattan-distances-of-all-arrangements-of-pieces.py) | 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](https://leetcode.com/problems/maximum-and-minimum-sums-of-at-most-size-k-subsequences/) | [C++](./C++/maximum-and-minimum-sums-of-at-most-size-k-subsequences.cpp) [Python](./Python/maximum-and-minimum-sums-of-at-most-size-k-subsequences.py) | _O(nlogn)_ | _O(n)_ | Medium | | Sort, Combinatorics, Two Pointers, Sliding Window |
3447 | [Assign Elements to Groups with Constraints](https://leetcode.com/problems/assign-elements-to-groups-with-constraints/) | [C++](./C++/assign-elements-to-groups-with-constraints.cpp) [Python](./Python/assign-elements-to-groups-with-constraints.py) | _O(m + r * logn)_ | _O(r)_ | Medium | | Hash Table, Number Theory |
3448 | [Count Substrings Divisible By Last Digit](https://leetcode.com/problems/count-substrings-divisible-by-last-digit/) | [C++](./C++/count-substrings-divisible-by-last-digit.cpp) [Python](./Python/count-substrings-divisible-by-last-digit.py) | _O(d * n)_ | _O(d)_ | Hard | | DP, Case Works, Math, Freq Table |
3461 | [Check If Digits Are Equal in String After Operations I](https://leetcode.com/problems/check-if-digits-are-equal-in-string-after-operations-i/) | [C++](./C++/check-if-digits-are-equal-in-string-after-operations-i.cpp) [Python](./Python/check-if-digits-are-equal-in-string-after-operations-i.py) | _O(nlogn)_ | _O(1)_ | Easy | | Fast Exponentiation, `Luca's Theorem`, Simulation
3463 | [Check If Digits Are Equal in String After Operations II](https://leetcode.com/problems/check-if-digits-are-equal-in-string-after-operations-ii/) | [C++](./C++/check-if-digits-are-equal-in-string-after-operations-ii.cpp) [Python](./Python/check-if-digits-are-equal-in-string-after-operations-ii.py) | _O(nlogn)_ | _O(1)_ | Hard | | Fast Exponentiation, `Lucas's Theorem`
3470 | [Permutations IV](https://leetcode.com/problems/permutations-iv/) | [C++](./C++/permutations-iv.cpp) [Python](./Python/permutations-iv.py) | _O(n^2)_ | _O(n)_ | Hard | | Combinatorics |
3483 | [Unique 3-Digit Even Numbers](https://leetcode.com/problems/unique-3-digit-even-numbers/) | [C++](./C++/unique-3-digit-even-numbers.cpp) [Python](./Python/unique-3-digit-even-numbers.py) | _O(n)_ | _O(1)_ | Easy | | Freq Table, Combinatorics |
3492 | [Maximum Containers on a Ship](https://leetcode.com/problems/maximum-containers-on-a-ship/) | [C++](./C++/maximum-containers-on-a-ship.cpp) [Python](./Python/maximum-containers-on-a-ship.py) | _O(1)_ | _O(1)_ | Easy | | Math |
3512 | [Minimum Operations to Make Array Sum Divisible by K](https://leetcode.com/problems/minimum-operations-to-make-array-sum-divisible-by-k/) | [C++](./C++/minimum-operations-to-make-array-sum-divisible-by-k.cpp) [Python](./Python/minimum-operations-to-make-array-sum-divisible-by-k.py) | _O(n)_ | _O(1)_ | Easy | | Math |
3513 | [Number of Unique XOR Triplets I](https://leetcode.com/problems/number-of-unique-xor-triplets-i/) | [C++](./C++/number-of-unique-xor-triplets-i.cpp) [Python](./Python/number-of-unique-xor-triplets-i.py) | _O(logn)_ | _O(1)_ | Medium | | Bit Manipulation, Math
3516 | [Find Closest Person](https://leetcode.com/problems/find-closest-person/) | [C++](./C++/find-closest-person.cpp) [Python](./Python/find-closest-person.py) | _O(1)_ | _O(1)_ | Easy | | Math |
3519 | [Count Numbers with Non-Decreasing Digits](https://leetcode.com/problems/count-numbers-with-non-decreasing-digits/) | [C++](./C++/count-numbers-with-non-decreasing-digits.cpp) [Python](./Python/count-numbers-with-non-decreasing-digits.py) | _O(n^2)_ | _O(n)_ | Hard | | Math, Stars and Bars, Combinatorics |
3556 | [Sum of Largest Prime Substrings](https://leetcode.com/problems/sum-of-largest-prime-substrings/) | [C++](./C++/sum-of-largest-prime-substrings.cpp) [Python](./Python/sum-of-largest-prime-substrings.py) | _O(n^2 * sqrt(r))_ | _O(n^2)_ | Medium | | Number Theory, Quick Select |
3560 | [Find Minimum Log Transportation Cost](https://leetcode.com/problems/find-minimum-log-transportation-cost/) | [C++](./C++/find-minimum-log-transportation-cost.cpp) [Python](./Python/find-minimum-log-transportation-cost.py) | _O(1)_ | _O(1)_ | Easy | | Math |
3577 | [Count the Number of Computer Unlocking Permutations](https://leetcode.com/problems/count-the-number-of-computer-unlocking-permutations/) | [C++](./C++/count-the-number-of-computer-unlocking-permutations.cpp) [Python](./Python/count-the-number-of-computer-unlocking-permutations.py) | _O(n)_ | _O(1)_ | Medium | | Combinatorics |
3588 | [Find Maximum Area of a Triangle](https://leetcode.com/problems/find-maximum-area-of-a-triangle/) | [C++](./C++/find-maximum-area-of-a-triangle.cpp) [Python](./Python/find-maximum-area-of-a-triangle.py) | _O(n)_ | _O(n)_ | Medium | | Math, Hash Table |
3596 | [Minimum Cost Path with Alternating Directions I](https://leetcode.com/problems/minimum-cost-path-with-alternating-directions-i/) | [C++](./C++/minimum-cost-path-with-alternating-directions-i.cpp) [Python](./Python/minimum-cost-path-with-alternating-directions-i.py) | _O(1)_ | _O(1)_ | Medium | 🔒 | Math |
3602 | [Hexadecimal and Hexatrigesimal Conversion](https://leetcode.com/problems/hexadecimal-and-hexatrigesimal-conversion/) | [C++](./C++/hexadecimal-and-hexatrigesimal-conversion.cpp) [Python](./Python/hexadecimal-and-hexatrigesimal-conversion.py) | _O(logn)_ | _O(1)_ | Easy | | Math |
3618 | [Split Array by Prime Indices](https://leetcode.com/problems/split-array-by-prime-indices/) | [C++](./C++/split-array-by-prime-indices.cpp) [Python](./Python/split-array-by-prime-indices.py) | 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](https://leetcode.com/problems/number-of-integers-with-popcount-depth-equal-to-k-i/) | [C++](./C++/number-of-integers-with-popcount-depth-equal-to-k-i.cpp) [Python](./Python/number-of-integers-with-popcount-depth-equal-to-k-i.py) | precompute: _O((logr)^2)_runtime: _O((logn)^2)_ | _O((logr)^2)_ | Hard | | Combinatorics |
3622 | [Check Divisibility by Digit Sum and Product](https://leetcode.com/problems/check-divisibility-by-digit-sum-and-product/) | [C++](./C++/check-divisibility-by-digit-sum-and-product.cpp) [Python](./Python/check-divisibility-by-digit-sum-and-product.py) | _O(logn)_ | _O(1)_ | Easy | | Math |
3623 | [Count Number of Trapezoids I](https://leetcode.com/problems/count-number-of-trapezoids-i/) | [C++](./C++/count-number-of-trapezoids-i.cpp) [Python](./Python/count-number-of-trapezoids-i.py) | _O(n)_ | _O(n)_ | Medium | | Freq Table, Combinatorics |
3624 | [Number of Integers With Popcount-Depth Equal to K II](https://leetcode.com/problems/number-of-integers-with-popcount-depth-equal-to-k-ii/) | [C++](./C++/number-of-integers-with-popcount-depth-equal-to-k-ii.cpp) [Python](./Python/number-of-integers-with-popcount-depth-equal-to-k-ii.py) | 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](https://leetcode.com/problems/count-number-of-trapezoids-ii/) | [C++](./C++/count-number-of-trapezoids-ii.cpp) [Python](./Python/count-number-of-trapezoids-ii.py) | _O(n^2 * logr)_ | _O(n^2)_ | Hard | | Freq Table, Combinatorics |
3648 | [Minimum Sensors to Cover Grid](https://leetcode.com/problems/minimum-sensors-to-cover-grid/) | [C++](./C++/minimum-sensors-to-cover-grid.cpp) [Python](./Python/minimum-sensors-to-cover-grid.py) | _O(1)_ | _O(1)_ | Medium | | Math |
3658 | [GCD of Odd and Even Sums](https://leetcode.com/problems/gcd-of-odd-and-even-sums/) | [C++](./C++/gcd-of-odd-and-even-sums.cpp) [Python](./Python/gcd-of-odd-and-even-sums.py) | _O(1)_ | _O(1)_ | Easy | | Math |
3659 | [Partition Array Into K-Distinct Groups](https://leetcode.com/problems/partition-array-into-k-distinct-groups/) | [C++](./C++/partition-array-into-k-distinct-groups.cpp) [Python](./Python/partition-array-into-k-distinct-groups.py) | _O(n)_ | _O(n)_ | Medium | | Math, Freq Table |
3664 | [Two-Letter Card Game](https://leetcode.com/problems/two-letter-card-game/) | [C++](./C++/two-letter-card-game.cpp) [Python](./Python/two-letter-card-game.py) | _O(n + 26)_ | _O(26)_ | Medium | | Math, Freq Table |
3666 | [Minimum Operations to Equalize Binary String](https://leetcode.com/problems/minimum-operations-to-equalize-binary-string/) | [C++](./C++/minimum-operations-to-equalize-binary-string.cpp) [Python](./Python/minimum-operations-to-equalize-binary-string.py) | _O(n)_ | _O(1)_ | Hard | | Math |
3671 | [Sum of Beautiful Subsequences](https://leetcode.com/problems/sum-of-beautiful-subsequences/) | [C++](./C++/sum-of-beautiful-subsequences.cpp) [Python](./Python/sum-of-beautiful-subsequences.py) | precompute: _O(rlogr)_runtime: _O(nlogr * (log(nlogr) + logn))_ | _O(rlogr)_ | Hard | | Number Theory, BIT, Fenwick Tree |
3677 | [Count Binary Palindromic Numbers](https://leetcode.com/problems/count-binary-palindromic-numbers/) | [C++](./C++/count-binary-palindromic-numbers.cpp) [Python](./Python/count-binary-palindromic-numbers.py) | _O(logn)_ | _O(1)_ | Hard | | Bitmasks, Combinatorics |
3697 | [Compute Decimal Representation](https://leetcode.com/problems/compute-decimal-representation/) | [C++](./C++/compute-decimal-representation.cpp) [Python](./Python/compute-decimal-representation.py) | _O(logn)_ | _O(1)_ | Easy | | Math |
3726 | [Remove Zeros in Decimal Representation](https://leetcode.com/problems/remove-zeros-in-decimal-representation/) | [C++](./C++/remove-zeros-in-decimal-representation.cpp) [Python](./Python/remove-zeros-in-decimal-representation.py) | _O(logn)_ | _O(1)_ | Easy | | Math, String |
3731 | [Find Missing Elements](https://leetcode.com/problems/find-missing-elements/) | [C++](./C++/find-missing-elements.cpp) [Python](./Python/find-missing-elements.py) | _O(n + r)_ | _O(n)_ | Easy | | Hash Table |
3745 | [Maximize Expression of Three Elements](https://leetcode.com/problems/maximize-expression-of-three-elements/) | [C++](./C++/maximize-expression-of-three-elements.cpp) [Python](./Python/maximize-expression-of-three-elements.py) | _O(n)_ | _O(1)_ | Easy | | Math |
3747 | [Count Distinct Integers After Removing Zeros](https://leetcode.com/problems/count-distinct-integers-after-removing-zeros/) | [C++](./C++/count-distinct-integers-after-removing-zeros.cpp) [Python](./Python/count-distinct-integers-after-removing-zeros.py) | _O(logn)_ | _O(1)_ | Medium | | Combinatorics |
3754 | [Concatenate Non-Zero Digits and Multiply by Sum I](https://leetcode.com/problems/concatenate-non-zero-digits-and-multiply-by-sum-i/) | [C++](./C++/concatenate-non-zero-digits-and-multiply-by-sum-i.cpp) [Python](./Python/concatenate-non-zero-digits-and-multiply-by-sum-i.py) | _O(logn)_ | _O(1)_ | Easy | | Math |
3765 | [Complete Prime Number](https://leetcode.com/problems/complete-prime-number/) | [C++](./C++/complete-prime-number.cpp) [Python](./Python/complete-prime-number.py) | _O(logn * sqrt(n))_ | _O(1)_ | Medium | | Prefix Sum, Number Theory |
3770 | [Largest Prime from Consecutive Prime Sum](https://leetcode.com/problems/largest-prime-from-consecutive-prime-sum/) | [C++](./C++/largest-prime-from-consecutive-prime-sum.cpp) [Python](./Python/largest-prime-from-consecutive-prime-sum.py) | 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](https://leetcode.com/problems/mirror-distance-of-an-integer/) | [C++](./C++/mirror-distance-of-an-integer.cpp) [Python](./Python/mirror-distance-of-an-integer.py) | _O(logn)_ | _O(1)_ | Easy || Math
3789 | [Minimum Cost to Acquire Required Items](https://leetcode.com/problems/minimum-cost-to-acquire-required-items/) | [C++](./C++/minimum-cost-to-acquire-required-items.cpp) [Python](./Python/minimum-cost-to-acquire-required-items.py) | _O(1)_ | _O(1)_ | Medium || Math
3790 | [Smallest All-Ones Multiple](https://leetcode.com/problems/smallest-all-ones-multiple/) | [C++](./C++/smallest-all-ones-multiple.cpp) [Python](./Python/smallest-all-ones-multiple.py) | _O(k)_ | _O(1)_ | Medium | duplicate of [Smallest Integer Divisible by K](https://leetcode.com/problems/smallest-integer-divisible-by-k/) | Math
3798 | [Largest Even Number](https://leetcode.com/problems/largest-even-number/) | [C++](./C++/largest-even-number.cpp) [Python](./Python/largest-even-number.py) | _O(n)_ | _O(1)_ | Easy | | Math
3800 | [Minimum Cost to Make Two Binary Strings Equal](https://leetcode.com/problems/minimum-cost-to-make-two-binary-strings-equal/) | [C++](./C++/minimum-cost-to-make-two-binary-strings-equal.cpp) [Python](./Python/minimum-cost-to-make-two-binary-strings-equal.py) | _O(n)_ | _O(1)_ | Medium | | Math
3817 | [Good Indices in a Digit String](https://leetcode.com/problems/good-indices-in-a-digit-string/) | [C++](./C++/good-indices-in-a-digit-string.cpp) [Python](./Python/good-indices-in-a-digit-string.py) | _O(n)_ | _O(1)_ | Medium | 🔒 | Math, Sliding Window
3821 | [Find Nth Smallest Integer With K One Bits](https://leetcode.com/problems/find-nth-smallest-integer-with-k-one-bits/) | [C++](./C++/find-nth-smallest-integer-with-k-one-bits.cpp) [Python](./Python/find-nth-smallest-integer-with-k-one-bits.py) | ctor: _O(r^2)_runtime: _O(r)_ | _O(r^2)_ | Hard | | DP, Combinatorics
3855 | [Sum of K-Digit Numbers in a Range](https://leetcode.com/problems/sum-of-k-digit-numbers-in-a-range/) | [C++](./C++/sum-of-k-digit-numbers-in-a-range.cpp) [Python](./Python/sum-of-k-digit-numbers-in-a-range.py) | _O(logr)_ | _O(1)_ | Hard | | Math
3857 | [Minimum Cost to Split into Ones](https://leetcode.com/problems/minimum-cost-to-split-into-ones/) | [C++](./C++/minimum-cost-to-split-into-ones.cpp) [Python](./Python/minimum-cost-to-split-into-ones.py) | _O(1)_ | _O(1)_ | Medium | | Combinatorics
3870 | [Count Commas in Range](https://leetcode.com/problems/count-commas-in-range/) | [C++](./C++/count-commas-in-range.cpp) [Python](./Python/count-commas-in-range.py) | _O(logn)_ | _O(1)_ | Easy | | Math
3871 | [Count Commas in Range II](https://leetcode.com/problems/count-commas-in-range-ii/) | [C++](./C++/count-commas-in-range-ii.cpp) [Python](./Python/count-commas-in-range-ii.py) | _O(logn)_ | _O(1)_ | Medium | | Math
3881 | [Direction Assignments with Exactly K Visible People](https://leetcode.com/problems/direction-assignments-with-exactly-k-visible-people/) | [C++](./C++/direction-assignments-with-exactly-k-visible-people.cpp) [Python](./Python/direction-assignments-with-exactly-k-visible-people.py) | _O(n)_ | _O(n)_ | Medium | | Combinatorics
3895 | [Count Digit Appearances](https://leetcode.com/problems/count-digit-appearances/) | [C++](./C++/count-digit-appearances.cpp) [Python](./Python/count-digit-appearances.py) | _O(nlogr)_ | _O(1)_ | Medium | | Math
3896 | [Count Digit Appearances](https://leetcode.com/problems/minimum-operations-to-transform-array-into-alternating-prime/) | [C++](./C++/minimum-operations-to-transform-array-into-alternating-prime.cpp) [Python](./Python/minimum-operations-to-transform-array-into-alternating-prime.py) | precompute: _O(r)_, runtime: _O(nlogn)_ | _O(r)_ | Medium | | Number Theory, `Linear Sieve of Eratosthenes`, Prime Gap, Binary Search
3899 | [Angles of a Triangle](https://leetcode.com/problems/angles-of-a-triangle/) | [C++](./C++/angles-of-a-triangle.cpp) [Python](./Python/angles-of-a-triangle.py) | _O(1)_ | _O(1)_ | Medium | | Math, Law of Cosines
3908 | [Valid Digit Number](https://leetcode.com/problems/valid-digit-number/) | [C++](./C++/valid-digit-number.cpp) [Python](./Python/valid-digit-number.py) | _O(logn)_ | _O(1)_ | Easy | | Math
3927 | [Minimize Array Sum Using Divisible Replacements](https://leetcode.com/problems/minimize-array-sum-using-divisible-replacements/) | [C++](./C++/minimize-array-sum-using-divisible-replacements.cpp) [Python](./Python/minimize-array-sum-using-divisible-replacements.py) | _O(n + rlogr)_ | _O(r)_ | Medium | | Number Theory
3954 | [Sum of Compatible Numbers in Range I](https://leetcode.com/problems/sum-of-compatible-numbers-in-range-i/) | [C++](./C++/sum-of-compatible-numbers-in-range-i.cpp) [Python](./Python/sum-of-compatible-numbers-in-range-i.py) | _O(log(n + k))_ | _O(1)_ | Easy | | Bitmasks, Combinatorics, Simulation
3958 | [Minimum Cost to Split into Ones II](https://leetcode.com/problems/minimum-cost-to-split-into-ones-ii/) | [C++](./C++/minimum-cost-to-split-into-ones-ii.cpp) [Python](./Python/minimum-cost-to-split-into-ones-ii.py) | _O(1)_ | _O(1)_ | Medium | 🔒 | Math, Invariant
3959 | [Check Good Integer](https://leetcode.com/problems/check-good-integer/) | [C++](./C++/check-good-integer.cpp) [Python](./Python/check-good-integer.py) | _O(logn)_ | _O(1)_ | Easy | | Math
3984 | [Divisible Game](https://leetcode.com/problems/divisible-game/) | [C++](./C++/divisible-game.cpp) [Python](./Python/divisible-game.py) | 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](https://leetcode.com/problems/minimum-total-cost-to-process-all-elements/) | [C++](./C++/minimum-total-cost-to-process-all-elements.cpp) [Python](./Python/minimum-total-cost-to-process-all-elements.py) | _O(n)_ | _O(1)_ | Medium | | Math
3993 | [Maximum Value of an Alternating Sequence](https://leetcode.com/problems/maximum-value-of-an-alternating-sequence/) | [C++](./C++/maximum-value-of-an-alternating-sequence.cpp) [Python](./Python/maximum-value-of-an-alternating-sequence.py) | _O(1)_ | _O(1)_ | Medium | | Math
3996 | [Even Number of Knight Moves](https://leetcode.com/problems/even-number-of-knight-moves/) | [C++](./C++/even-number-of-knight-moves.cpp) [Python](./Python/even-number-of-knight-moves.py) | _O(1)_ | _O(1)_ | Easy | | Math, Parity
4002 | [Count Valid Sequences](https://leetcode.com/problems/count-valid-sequences/) | [C++](./C++/count-valid-sequences.cpp) [Python](./Python/count-valid-sequences.py) | _O(n)_ | _O(n)_ | Medium | | Combinatorics, Stars and Bars



    **[⬆️ Back to Top](#algorithms)**



## Sort
|  #  | Title           |  Solution       |  Time           | Space           | Difficulty    | Tag          | Note| 
|-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------|-----|
3011 | [Find if Array Can Be Sorted](https://leetcode.com/problems/find-if-array-can-be-sorted/) | [C++](./C++/find-if-array-can-be-sorted.cpp) [Python](./Python/find-if-array-can-be-sorted.py) | _O(n)_   | _O(1)_        | Medium         | | Sort
3025 | [Find the Number of Ways to Place People I](https://leetcode.com/problems/find-the-number-of-ways-to-place-people-i/) | [C++](./C++/find-the-number-of-ways-to-place-people-i.cpp) [Python](./Python/find-the-number-of-ways-to-place-people-i.py) | _O(n^2)_   | _O(1)_        | Medium         | | Sort, Array
3027 | [Find the Number of Ways to Place People II](https://leetcode.com/problems/find-the-number-of-ways-to-place-people-ii/) | [C++](./C++/find-the-number-of-ways-to-place-people-ii.cpp) [Python](./Python/find-the-number-of-ways-to-place-people-ii.py) | _O(n^2)_   | _O(1)_        | Hard         | | Sort, Array
3081 | [Replace Question Marks in String to Minimize Its Value](https://leetcode.com/problems/replace-question-marks-in-string-to-minimize-its-value/) | [C++](./C++/replace-question-marks-in-string-to-minimize-its-value.cpp) [Python](./Python/replace-question-marks-in-string-to-minimize-its-value.py) | _O(n + 26 * log(26))_   | _O(n + 26)_        | Medium         | | Greedy, Counting Sort, Heap, Prefix Sum
3132 | [Find the Integer Added to Array II](https://leetcode.com/problems/find-the-integer-added-to-array-ii/) | [C++](./C++/find-the-integer-added-to-array-ii.cpp) [Python](./Python/find-the-integer-added-to-array-ii.py) | _O(n)_ | _O(n)_ | Medium | | Sort, Paritial Sort, Freq Table
3169 | [Count Days Without Meetings](https://leetcode.com/problems/count-days-without-meetings/) | [C++](./C++/count-days-without-meetings.cpp) [Python](./Python/count-days-without-meetings.py) | _O(nlogn)_ | _O(1)_ | Medium | | Sort
3194 | [Minimum Average of Smallest and Largest Elements](https://leetcode.com/problems/minimum-average-of-smallest-and-largest-elements/) | [C++](./C++/minimum-average-of-smallest-and-largest-elements.cpp) [Python](./Python/minimum-average-of-smallest-and-largest-elements.py) | _O(nlogn)_ | _O(1)_ | Easy | | Sort
3309 | [Maximum Possible Number by Binary Concatenation](https://leetcode.com/problems/maximum-possible-number-by-binary-concatenation/) | [C++](./C++/maximum-possible-number-by-binary-concatenation.cpp) [Python](./Python/maximum-possible-number-by-binary-concatenation.py) | _O(n * logr * logn)_ | _O(nlogr)_ | Medium | | Sort, Brute Force
3394 | [Check if Grid can be Cut into Sections](https://leetcode.com/problems/check-if-grid-can-be-cut-into-sections/) | [C++](./C++/check-if-grid-can-be-cut-into-sections.cpp) [Python](./Python/check-if-grid-can-be-cut-into-sections.py) | _O(nlogn)_ | _O(1)_ | Medium | | Sort, Merge Intervals
3431 | [Minimum Unlocked Indices to Sort Nums](https://leetcode.com/problems/minimum-unlocked-indices-to-sort-nums/) | [C++](./C++/minimum-unlocked-indices-to-sort-nums.cpp) [Python](./Python/minimum-unlocked-indices-to-sort-nums.py) | _O(n)_ | _O(1)_ | Medium | | Sort
3551 | [Minimum Swaps to Sort by Digit Sum](https://leetcode.com/problems/minimum-swaps-to-sort-by-digit-sum/) | [C++](./C++/minimum-swaps-to-sort-by-digit-sum.cpp) [Python](./Python/minimum-swaps-to-sort-by-digit-sum.py) | _O(nlogr + nlogn)_ | _O(n)_ | Medium | | Sort
3631 | [Sort Threats by Severity and Exploitability](https://leetcode.com/problems/sort-threats-by-severity-and-exploitability/) | [C++](./C++/sort-threats-by-severity-and-exploitability.cpp) [Python](./Python/sort-threats-by-severity-and-exploitability.py) | _O(nlogn)_ | _O(1)_ | Medium | 🔒 | Sort
3644 | [Maximum K to Sort a Permutation](https://leetcode.com/problems/maximum-k-to-sort-a-permutation/) | [C++](./C++/maximum-k-to-sort-a-permutation.cpp) [Python](./Python/maximum-k-to-sort-a-permutation.py) | _O(n)_ | _O(1)_ | Medium | | Sort, Bitmasks, Constructive Algorithms
3667 | [Sort Array By Absolute Value](https://leetcode.com/problems/sort-array-by-absolute-value/) | [C++](./C++/sort-array-by-absolute-value.cpp) [Python](./Python/sort-array-by-absolute-value.py) | _O(n + r)_ | _O(n + r)_ | Easy | 🔒 | Sort
3759 | [Count Elements With at Least K Greater Values](https://leetcode.com/problems/count-elements-with-at-least-k-greater-values/) | [C++](./C++/count-elements-with-at-least-k-greater-values.cpp) [Python](./Python/count-elements-with-at-least-k-greater-values.py) | _O(n)_ | _O(1)_ | Medium | | Sort, Quick Select
3780 | [Maximum Sum of Three Numbers Divisible by Three](https://leetcode.com/problems/maximum-sum-of-three-numbers-divisible-by-three/) | [C++](./C++/maximum-sum-of-three-numbers-divisible-by-three.cpp) [Python](./Python/maximum-sum-of-three-numbers-divisible-by-three.py) | _O(n)_ | _O(1)_ | Medium | | Sort, Math
3799 | [Word Squares II](https://leetcode.com/problems/word-squares-ii/) | [C++](./C++/word-squares-ii.cpp) [Python](./Python/word-squares-ii.py) | _O(n^4)_ | _O(1)_ | Medium | | Sort, Brute Force, Hash Table
3975 | [Filter Occupied Intervals](https://leetcode.com/problems/filter-occupied-intervals/) | [C++](./C++/filter-occupied-intervals.cpp) [Python](./Python/filter-occupied-intervals.py) | _O(nlogn)_ | _O(n)_ | Medium | | Sort



    **[⬆️ Back to Top](#algorithms)**



## Two Pointers
|  #  | Title           |  Solution       |  Time           | Space           | Difficulty    | Tag          | Note| 
|-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------|-----|
3006 | [Find Beautiful Indices in the Given Array I](https://leetcode.com/problems/find-beautiful-indices-in-the-given-array-i/) | [C++](./C++/find-beautiful-indices-in-the-given-array-i.cpp) [Python](./Python/find-beautiful-indices-in-the-given-array-i.py) | _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](https://leetcode.com/problems/find-beautiful-indices-in-the-given-array-ii/) | [C++](./C++/find-beautiful-indices-in-the-given-array-ii.cpp) [Python](./Python/find-beautiful-indices-in-the-given-array-ii.py) | _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](https://leetcode.com/problems/divide-an-array-into-subarrays-with-minimum-cost-ii/) | [C++](./C++/divide-an-array-into-subarrays-with-minimum-cost-ii.cpp) [Python](./Python/divide-an-array-into-subarrays-with-minimum-cost-ii.py) | _O(nlogd)_ | _O(d)_ | Hard | | Sliding Window, Heap, Freq Table, Ordered Set, BST, Sorted List
3085 | [Minimum Deletions to Make String K-Special](https://leetcode.com/problems/minimum-deletions-to-make-string-k-special/) | [C++](./C++/minimum-deletions-to-make-string-k-special.cpp) [Python](./Python/minimum-deletions-to-make-string-k-special.py) | _O(n + 26)_ | _O(n + 26)_ | Medium | | Freq Table, Counting Sort, Two Pointers
3090 | [Maximum Length Substring With Two Occurrences](https://leetcode.com/problems/maximum-length-substring-with-two-occurrences/) | [C++](./C++/maximum-length-substring-with-two-occurrences.cpp) [Python](./Python/maximum-length-substring-with-two-occurrences.py) | _O(n + 26)_ | _O(26)_ | Easy | | Freq Table, Sliding Window, Two Pointers
3095 | [Shortest Subarray With OR at Least K I](https://leetcode.com/problems/shortest-subarray-with-or-at-least-k-i/) | [C++](./C++/shortest-subarray-with-or-at-least-k-i.cpp) [Python](./Python/shortest-subarray-with-or-at-least-k-i.py) | _O(n * 30)_ | _O(30)_ | Easy | | Brute Force, Freq Table, Two Pointers
3097 | [Shortest Subarray With OR at Least K II](https://leetcode.com/problems/shortest-subarray-with-or-at-least-k-ii/) | [C++](./C++/shortest-subarray-with-or-at-least-k-ii.cpp) [Python](./Python/shortest-subarray-with-or-at-least-k-ii.py) | _O(n * 30)_ | _O(30)_ | Medium | | Freq Table, Two Pointers
3171 | [Find Subarray With Bitwise OR Closest to K](https://leetcode.com/problems/find-subarray-with-bitwise-or-closest-to-k/)| [C++](./C++/find-subarray-with-bitwise-or-closest-to-k.cpp) [Python](./Python/find-subarray-with-bitwise-or-closest-to-k.py) | _O(nlogr)_    | _O(logr)_          | Hard           | variant of [Find a Value of a Mysterious Function Closest to Target](https://leetcode.com/problems/find-a-value-of-a-mysterious-function-closest-to-target/) | DP, Freq Table, Two Pointers, Sliding Window
3206 | [Alternating Groups I](https://leetcode.com/problems/alternating-groups-i/)| [C++](./C++/alternating-groups-i.cpp) [Python](./Python/alternating-groups-i.py) | _O(n)_    | _O(1)_          | Easy           |  | Two Pointers, Sliding Window
3208 | [Alternating Groups II](https://leetcode.com/problems/alternating-groups-ii/)| [C++](./C++/alternating-groups-ii.cpp) [Python](./Python/alternating-groups-ii.py) | _O(n)_    | _O(1)_          | Medium           |  | Two Pointers, Sliding Window
3234 | [Count the Number of Substrings With Dominant Ones](https://leetcode.com/problems/count-the-number-of-substrings-with-dominant-ones/)| [C++](./C++/count-the-number-of-substrings-with-dominant-ones.cpp) [Python](./Python/count-the-number-of-substrings-with-dominant-ones.py) | _O(n^(3/2))_    | _O(1)_          | Medium           |  | Two Pointers, Sliding Window
3254 | [Find the Power of K-Size Subarrays I](https://leetcode.com/problems/find-the-power-of-k-size-subarrays-i/)| [C++](./C++/find-the-power-of-k-size-subarrays-i.cpp) [Python](./Python/find-the-power-of-k-size-subarrays-i.py) | _O(n)_    | _O(1)_          | Medium           |  | Two Pointers, Sliding Window
3255 | [Find the Power of K-Size Subarrays II](https://leetcode.com/problems/find-the-power-of-k-size-subarrays-ii/)| [C++](./C++/find-the-power-of-k-size-subarrays-ii.cpp) [Python](./Python/find-the-power-of-k-size-subarrays-ii.py) | _O(n)_    | _O(1)_          | Medium           |  | Two Pointers, Sliding Window
3258 | [Count Substrings That Satisfy K-Constraint I](https://leetcode.com/problems/count-substrings-that-satisfy-k-constraint-i/)| [C++](./C++/count-substrings-that-satisfy-k-constraint-i.cpp) [Python](./Python/count-substrings-that-satisfy-k-constraint-i.py) | _O(n)_    | _O(1)_          | Easy           |  | Two Pointers, Sliding Window
3261 | [Count Substrings That Satisfy K-Constraint II](https://leetcode.com/problems/count-substrings-that-satisfy-k-constraint-ii/)| [C++](./C++/count-substrings-that-satisfy-k-constraint-ii.cpp) [Python](./Python/count-substrings-that-satisfy-k-constraint-ii.py) | _O(n)_    | _O(n)_          | Hard           |  | Two Pointers, Sliding Window, Prefix Sum, Hash Table
3264 | [Final Array State After K Multiplication Operations I](https://leetcode.com/problems/final-array-state-after-k-multiplication-operations-i/)| [C++](./C++/final-array-state-after-k-multiplication-operations-i.cpp) [Python](./Python/final-array-state-after-k-multiplication-operations-i.py) | _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](https://leetcode.com/problems/final-array-state-after-k-multiplication-operations-ii/)| [C++](./C++/final-array-state-after-k-multiplication-operations-ii.cpp) [Python](./Python/final-array-state-after-k-multiplication-operations-ii.py) | _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](https://leetcode.com/problems/count-substrings-that-can-be-rearranged-to-contain-a-string-i/)| [C++](./C++/count-substrings-that-can-be-rearranged-to-contain-a-string-i.cpp) [Python](./Python/count-substrings-that-can-be-rearranged-to-contain-a-string-i.py) | _O(n + 26)_    | _O(26)_          | Medium           |  | Two Pointers, Sliding Window, Freq Table
3298 | [Count Substrings That Can Be Rearranged to Contain a String II](https://leetcode.com/problems/count-substrings-that-can-be-rearranged-to-contain-a-string-ii/)| [C++](./C++/count-substrings-that-can-be-rearranged-to-contain-a-string-ii.cpp) [Python](./Python/count-substrings-that-can-be-rearranged-to-contain-a-string-ii.py) | _O(n + 26)_    | _O(26)_          | Hard           |  | Two Pointers, Sliding Window, Freq Table
3305 | [Count of Substrings Containing Every Vowel and K Consonants I](https://leetcode.com/problems/count-of-substrings-containing-every-vowel-and-k-consonants-i/)| [C++](./C++/count-of-substrings-containing-every-vowel-and-k-consonants-i.cpp) [Python](./Python/count-of-substrings-containing-every-vowel-and-k-consonants-i.py) | _O(n)_    | _O(1)_          | Medium           |  | Two Pointers, Sliding Window, Freq Table
3306 | [Count of Substrings Containing Every Vowel and K Consonants II](https://leetcode.com/problems/count-of-substrings-containing-every-vowel-and-k-consonants-ii/)| [C++](./C++/count-of-substrings-containing-every-vowel-and-k-consonants-ii.cpp) [Python](./Python/count-of-substrings-containing-every-vowel-and-k-consonants-ii.py) | _O(n)_    | _O(1)_          | Medium           |  | Two Pointers, Sliding Window, Freq Table
3318 | [Find X-Sum of All K-Long Subarrays I](https://leetcode.com/problems/find-x-sum-of-all-k-long-subarrays-i/)| [C++](./C++/find-x-sum-of-all-k-long-subarrays-i.cpp) [Python](./Python/find-x-sum-of-all-k-long-subarrays-i.py) | _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](https://leetcode.com/problems/find-x-sum-of-all-k-long-subarrays-ii/)| [C++](./C++/find-x-sum-of-all-k-long-subarrays-ii.cpp) [Python](./Python/find-x-sum-of-all-k-long-subarrays-ii.py) | _O(nlogn)_    | _O(n)_          | Hard           |  | Two Pointers, Sliding Window, Freq Table, Ordered Set, Sorted List
3323 | [Minimize Connected Groups by Inserting Interval](https://leetcode.com/problems/minimize-connected-groups-by-inserting-interval/) | [C++](./C++/minimize-connected-groups-by-inserting-interval.cpp) [Python](./Python/minimize-connected-groups-by-inserting-interval.py) | _O(nlogn)_ | _O(n)_ | Medium | 🔒 | Sort, Prefix Sum, Two Pointers, Sliding Window
3325 | [Count Substrings With K-Frequency Characters I](https://leetcode.com/problems/count-substrings-with-k-frequency-characters-i/) | [C++](./C++/count-substrings-with-k-frequency-characters-i.cpp) [Python](./Python/count-substrings-with-k-frequency-characters-i.py) | _O(n + 26)_ | _O(26)_ | Medium | | Freq Table, Two Pointers, Sliding Window
3329 | [Count Substrings With K-Frequency Characters II](https://leetcode.com/problems/count-substrings-with-k-frequency-characters-ii/) | [C++](./C++/count-substrings-with-k-frequency-characters-ii.cpp) [Python](./Python/count-substrings-with-k-frequency-characters-ii.py) | _O(n + 26)_ | _O(26)_ | Hard | 🔒 | Freq Table, Two Pointers, Sliding Window
3346 | [Maximum Frequency of an Element After Performing Operations I](https://leetcode.com/problems/maximum-frequency-of-an-element-after-performing-operations-i/) | [C++](./C++/maximum-frequency-of-an-element-after-performing-operations-i.cpp) [Python](./Python/maximum-frequency-of-an-element-after-performing-operations-i.py) | _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](https://leetcode.com/problems/maximum-frequency-of-an-element-after-performing-operations-ii/) | [C++](./C++/maximum-frequency-of-an-element-after-performing-operations-ii.cpp) [Python](./Python/maximum-frequency-of-an-element-after-performing-operations-ii.py) | _O(nlogn)_ | _O(n)_ | Hard | | Sort, Freq Table, Two Pointers, Sliding Window, Difference Array, Line Sweep
3364 | [Minimum Positive Sum Subarray](https://leetcode.com/problems/minimum-positive-sum-subarray/) | [C++](./C++/minimum-positive-sum-subarray.cpp) [Python](./Python/minimum-positive-sum-subarray.py) | _O(nlogn)_ | _O(n)_ | Easy | | Prefix Sum, Two Pointers, Sliding Window, Sorted List, BST, Binary Search
3413 | [Maximum Coins From K Consecutive Bags](https://leetcode.com/problems/maximum-coins-from-k-consecutive-bags/) | [C++](./C++/maximum-coins-from-k-consecutive-bags.cpp) [Python](./Python/maximum-coins-from-k-consecutive-bags.py) | _O(nlogn)_ | _O(1)_ | Medium | | Sort, Two Pointers, Sliding Window
3420 | [Count Non-Decreasing Subarrays After K Operations](https://leetcode.com/problems/count-non-decreasing-subarrays-after-k-operations/) | [C++](./C++/count-non-decreasing-subarrays-after-k-operations.cpp) [Python](./Python/count-non-decreasing-subarrays-after-k-operations.py) | _O(n)_ | _O(n)_ | Hard | | Mono Deque, Two Pointers, Sliding Window
3422 | [Minimum Operations to Make Subarray Elements Equal](https://leetcode.com/problems/minimum-operations-to-make-subarray-elements-equal/) | [C++](./C++/minimum-operations-to-make-subarray-elements-equal.cpp) [Python](./Python/minimum-operations-to-make-subarray-elements-equal.py) | _O(nlogk)_ | _O(k)_ | Medium | 🔒 | Math, Two Pointers, Sliding Window, Sorted List, BST
3425 | [Longest Special Path](https://leetcode.com/problems/longest-special-path/) | [C++](./C++/longest-special-path.cpp) [Python](./Python/longest-special-path.py) | _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](https://leetcode.com/problems/maximum-and-minimum-sums-of-at-most-size-k-subarrays/) | [C++](./C++/maximum-and-minimum-sums-of-at-most-size-k-subarrays.cpp) [Python](./Python/maximum-and-minimum-sums-of-at-most-size-k-subarrays.py) | _O(n)_ | _O(k)_ | Hard | | Two Pointers, Sliding Window, Mono Deque
3439 | [Reschedule Meetings for Maximum Free Time I](https://leetcode.com/problems/reschedule-meetings-for-maximum-free-time-i/) | [C++](./C++/reschedule-meetings-for-maximum-free-time-i.cpp) [Python](./Python/reschedule-meetings-for-maximum-free-time-i.py) | _O(n)_ | _O(1)_ | Medium | | Two Pointers, Sliding Window
3445 | [Maximum Difference Between Even and Odd Frequency II](https://leetcode.com/problems/maximum-difference-between-even-and-odd-frequency-ii/) | [C++](./C++/maximum-difference-between-even-and-odd-frequency-ii.cpp) [Python](./Python/maximum-difference-between-even-and-odd-frequency-ii.py) | _O(d^2 * n)_ | _O(n)_ | Hard | | Prefix Sum, Two Pointers, Sliding Window
3460 | [Longest Common Prefix After at Most One Removal](https://leetcode.com/problems/longest-common-prefix-after-at-most-one-removal/) | [C++](./C++/longest-common-prefix-after-at-most-one-removal.cpp) [Python](./Python/longest-common-prefix-after-at-most-one-removal.py) | _O(n)_ | _O(1)_ | Medium | 🔒 | Two Pointers
3485 | [Longest Common Prefix of K Strings After Removal](https://leetcode.com/problems/longest-common-prefix-of-k-strings-after-removal/) | [C++](./C++/longest-common-prefix-of-k-strings-after-removal.cpp) [Python](./Python/longest-common-prefix-of-k-strings-after-removal.py) | _O(l * nlogn)_ | _O(n)_ | Hard | | Sort, Sliding Window, Prefix Sum, Trie
3486 | [Longest Special Path II](https://leetcode.com/problems/longest-special-path-ii/) | [C++](./C++/longest-special-path-ii.cpp) [Python](./Python/longest-special-path-ii.py) | _O(n + e)_ | _O(n + e)_ | Hard | | DFS, Two Pointers, Sliding Window, Prefix Sum
3555 | [Smallest Subarray to Sort in Every Sliding Window](https://leetcode.com/problems/smallest-subarray-to-sort-in-every-sliding-window/) | [C++](./C++/smallest-subarray-to-sort-in-every-sliding-window.cpp) [Python](./Python/smallest-subarray-to-sort-in-every-sliding-window.py) | _O(n)_ | _O(n)_ | Medium | 🔒 | Mono Stack, Two Pointers
3567 | [Minimum Absolute Difference in Sliding Submatrix](https://leetcode.com/problems/minimum-absolute-difference-in-sliding-submatrix/) | [C++](./C++/minimum-absolute-difference-in-sliding-submatrix.cpp) [Python](./Python/minimum-absolute-difference-in-sliding-submatrix.py) | _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](https://leetcode.com/problems/maximum-product-of-first-and-last-elements-of-a-subsequence/) | [C++](./C++/maximum-product-of-first-and-last-elements-of-a-subsequence.cpp) [Python](./Python/maximum-product-of-first-and-last-elements-of-a-subsequence.py) | _O(n)_ | _O(1)_ | Medium | | Two Pointers, Sliding Window
3589 | [Count Prime-Gap Balanced Subarrays](https://leetcode.com/problems/count-prime-gap-balanced-subarrays/) | [C++](./C++/count-prime-gap-balanced-subarrays.cpp) [Python](./Python/count-prime-gap-balanced-subarrays.py) | 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](https://leetcode.com/problems/minimum-removals-to-balance-array/) | [C++](./C++/minimum-removals-to-balance-array.cpp) [Python](./Python/minimum-removals-to-balance-array.py) | _O(nlogn)_ | _O(1)_ | Medium | | Sort, Two Pointers, Sliding Window
3640 | [Trionic Array II](https://leetcode.com/problems/trionic-array-ii/) | [C++](./C++/trionic-array-ii.cpp) [Python](./Python/trionic-array-ii.py) | _O(n)_ | _O(1)_ | Easy | | Two Pointers, Sliding Window, Greedy
3641 | [Longest Semi-Repeating Subarray](https://leetcode.com/problems/longest-semi-repeating-subarray/) | [C++](./C++/longest-semi-repeating-subarray.cpp) [Python](./Python/longest-semi-repeating-subarray.py) | _O(n)_ | _O(1)_ | Medium | 🔒 | Freq Table, Two Pointers, Sliding Window
3649 | [Number of Perfect Pairs](https://leetcode.com/problems/number-of-perfect-pairs/) | [C++](./C++/number-of-perfect-pairs.cpp) [Python](./Python/number-of-perfect-pairs.py) | _O(nlogn)_ | _O(1)_ | Medium | | Sort, Two Pointers, Sliding Window, Math
3652 | [Best Time to Buy and Sell Stock using Strategy](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-using-strategy/) | [C++](./C++/best-time-to-buy-and-sell-stock-using-strategy.cpp) [Python](./Python/best-time-to-buy-and-sell-stock-using-strategy.py) | _O(n)_ | _O(1)_ | Medium | | Two Pointers, Sliding Window
3672 | [Sum of Weighted Modes in Subarrays](https://leetcode.com/problems/sum-of-weighted-modes-in-subarrays/) | [C++](./C++/sum-of-weighted-modes-in-subarrays.cpp) [Python](./Python/sum-of-weighted-modes-in-subarrays.py) | _O(nlogk)_ | _O(k)_ | Medium | 🔒 | Sorted List, BST, Two Pointers, Sliding Window
3679 | [Minimum Discards to Balance Inventory](https://leetcode.com/problems/minimum-discards-to-balance-inventory/) | [C++](./C++/minimum-discards-to-balance-inventory.cpp) [Python](./Python/minimum-discards-to-balance-inventory.py) | _O(n)_ | _O(w)_ | Medium | | Freq Table, Two Pointers, Sliding Window
3698 | [Split Array With Minimum Difference](https://leetcode.com/problems/split-array-with-minimum-difference/) | [C++](./C++/split-array-with-minimum-difference.cpp) [Python](./Python/split-array-with-minimum-difference.py) | _O(n)_ | _O(1)_ | Medium | | Two Pointers
3740 | [Minimum Distance Between Three Equal Elements I](https://leetcode.com/problems/minimum-distance-between-three-equal-elements-i/) | [C++](./C++/minimum-distance-between-three-equal-elements-i.cpp) [Python](./Python/minimum-distance-between-three-equal-elements-i.py) | _O(n)_ | _O(n)_ | Easy | | Hash Table, Two Pointers, Sliding Window
3741 | [Minimum Distance Between Three Equal Elements II](https://leetcode.com/problems/minimum-distance-between-three-equal-elements-ii/) | [C++](./C++/minimum-distance-between-three-equal-elements-ii.cpp) [Python](./Python/minimum-distance-between-three-equal-elements-ii.py) | _O(n)_ | _O(n)_ | Medium | | Hash Table, Two Pointers, Sliding Window
3768 | [Minimum Inversion Count in Subarrays of Fixed Length](https://leetcode.com/problems/minimum-inversion-count-in-subarrays-of-fixed-length/) | [C++](./C++/minimum-inversion-count-in-subarrays-of-fixed-length.cpp) [Python](./Python/minimum-inversion-count-in-subarrays-of-fixed-length.py) | _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](https://leetcode.com/problems/minimum-subarray-length-with-distinct-sum-at-least-k/) | [C++](./C++/minimum-subarray-length-with-distinct-sum-at-least-k.cpp) [Python](./Python/minimum-subarray-length-with-distinct-sum-at-least-k.py) | _O(n)_ | _O(n)_ | Medium | | Freq Table, Two Pointers, Sliding Window
3802 | [Number of Ways to Paint Sheets](https://leetcode.com/problems/number-of-ways-to-paint-sheets/) | [C++](./C++/number-of-ways-to-paint-sheets.cpp) [Python](./Python/number-of-ways-to-paint-sheets.py) | _O(mlogm)_ | _O(m)_ | Hard | 🔒 | Prefix Sum, Two Pointers
3835 | [Count Subarrays With Cost Less Than or Equal to K](https://leetcode.com/problems/count-subarrays-with-cost-less-than-or-equal-to-k/) | [C++](./C++/count-subarrays-with-cost-less-than-or-equal-to-k.cpp) [Python](./Python/count-subarrays-with-cost-less-than-or-equal-to-k.py) | _O(n)_ | _O(n)_ | Medium | | Mono Deque, Two Pointers, Sliding Window
3844 | [Longest Almost-Palindromic Substring](https://leetcode.com/problems/longest-almost-palindromic-substring/) | [C++](./C++/longest-almost-palindromic-substring.cpp) [Python](./Python/longest-almost-palindromic-substring.py) | _O(n^2)_ | _O(1)_ | Medium | | Two Pointers
3845 | [Maximum Subarray XOR with Bounded Range](https://leetcode.com/problems/maximum-subarray-xor-with-bounded-range/) | [C++](./C++/maximum-subarray-xor-with-bounded-range.cpp) [Python](./Python/maximum-subarray-xor-with-bounded-range.py) | _O(nlogr)_ | _O(n)_ | Hard | | Two Pointers, Sliding Window, Mono Deque, Bitmasks, Prefix Sum, Trie, Hash Table
3851 | [Maximum Requests Without Violating the Limit](https://leetcode.com/problems/maximum-requests-without-violating-the-limit/) | [C++](./C++/maximum-requests-without-violating-the-limit.cpp) [Python](./Python/maximum-requests-without-violating-the-limit.py) | _O(nlogn)_ | _O(n)_ | Medium | 🔒 | Hash Table, Sort, Deque, Two Pointers, Sliding Window
3859 | [Count Subarrays With K Distinct Integers](https://leetcode.com/problems/count-subarrays-with-k-distinct-integers/) | [C++](./C++/count-subarrays-with-k-distinct-integers.cpp) [Python](./Python/count-subarrays-with-k-distinct-integers.py) | _O(n)_ | _O(n)_ | Hard | | Freq Table, Two Pointers, Sliding Window
3872 | [Longest Arithmetic Sequence After Changing At Most One Element](https://leetcode.com/problems/longest-arithmetic-sequence-after-changing-at-most-one-element/) | [C++](./C++/longest-arithmetic-sequence-after-changing-at-most-one-element.cpp) [Python](./Python/longest-arithmetic-sequence-after-changing-at-most-one-element.py) | _O(n)_ | _O(1)_ | Medium | | Two Pointers
3874 | [Valid Subarrays With Exactly One Peak](https://leetcode.com/problems/valid-subarrays-with-exactly-one-peak/) | [C++](./C++/valid-subarrays-with-exactly-one-peak.cpp) [Python](./Python/valid-subarrays-with-exactly-one-peak.py) | _O(n)_ | _O(1)_ | Medium | 🔒 | Combinatorics, Two Pointers
3937 | [Minimum Operations to Make Array Modulo Alternating I](https://leetcode.com/problems/minimum-operations-to-make-array-modulo-alternating-i/) | [C++](./C++/minimum-operations-to-make-array-modulo-alternating-i.cpp) [Python](./Python/minimum-operations-to-make-array-modulo-alternating-i.py) | _O(n + k)_ | _O(k)_ | Medium | | Freq Table, Two Pointers, Sliding Window
3944 | [Minimum Operations to Make Array Modulo Alternating II](https://leetcode.com/problems/minimum-operations-to-make-array-modulo-alternating-ii/) | [C++](./C++/minimum-operations-to-make-array-modulo-alternating-ii.cpp) [Python](./Python/minimum-operations-to-make-array-modulo-alternating-ii.py) | _O(n + k)_ | _O(k)_ | Hard | 🔒 | Freq Table, Two Pointers, Sliding Window
3969 | [Valid Subarrays With Matching Sum Digits I](https://leetcode.com/problems/valid-subarrays-with-matching-sum-digits-i/) | [C++](./C++/valid-subarrays-with-matching-sum-digits-i.cpp) [Python](./Python/valid-subarrays-with-matching-sum-digits-i.py) | _O(nlogr)_ | _O(n)_ | Medium | | Brute Force, Prefix Sum, Two Pointers, Sliding Window
3972 | [Valid Subarrays With Matching Sum Digits II](https://leetcode.com/problems/valid-subarrays-with-matching-sum-digits-ii/) | [C++](./C++/valid-subarrays-with-matching-sum-digits-ii.cpp) [Python](./Python/valid-subarrays-with-matching-sum-digits-ii.py) | _O(nlogr)_ | _O(n)_ | Hard | 🔒 | Prefix Sum, Two Pointers, Sliding Window
3992 | [Rearrange String to Avoid Character Pair](https://leetcode.com/problems/rearrange-string-to-avoid-character-pair/) | [C++](./C++/rearrange-string-to-avoid-character-pair.cpp) [Python](./Python/rearrange-string-to-avoid-character-pair.py) | _O(n)_ | _O(1)_ | Easy |  | Two Pointers
4001 | [Aggregate Two Time Series](https://leetcode.com/problems/aggregate-two-time-series/) | [C++](./C++/aggregate-two-time-series.cpp) [Python](./Python/aggregate-two-time-series.py) | _O(n + m)_ | _O(1)_ | Medium |  | Two Pointers



    **[⬆️ Back to Top](#algorithms)**



## Recursion
|  #  | Title           |  Solution       |  Time           | Space           | Difficulty    | Tag          | Note| 
|-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------|-----|



    **[⬆️ Back to Top](#algorithms)**



## Binary Search
|  #  | Title           |  Solution       |  Time           | Space           | Difficulty    | Tag          | Note| 
|-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------|-----|
3048 | [Earliest Second to Mark Indices I](https://leetcode.com/problems/earliest-second-to-mark-indices-i/) | [C++](./C++/earliest-second-to-mark-indices-i.cpp) [Python](./Python/earliest-second-to-mark-indices-i.py) | _O(mlogm)_ | _O(n)_ | Medium | | Binary Search, Greedy |
3049 | [Earliest Second to Mark Indices II](https://leetcode.com/problems/earliest-second-to-mark-indices-ii/) | [C++](./C++/earliest-second-to-mark-indices-ii.cpp) [Python](./Python/earliest-second-to-mark-indices-ii.py) | _O((m + nlogn) *logm)_ | _O(n)_ | Hard | | Binary Search, Greedy, Heap |
3104 | [Find Longest Self-Contained Substring](https://leetcode.com/problems/find-longest-self-contained-substring/) | [C++](./C++/find-longest-self-contained-substring.cpp) [Python](./Python/find-longest-self-contained-substring.py) | _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](https://leetcode.com/problems/kth-smallest-amount-with-single-denomination-combination/) | [C++](./C++/kth-smallest-amount-with-single-denomination-combination.cpp) [Python](./Python/kth-smallest-amount-with-single-denomination-combination.py) | _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](https://leetcode.com/problems/find-the-median-of-the-uniqueness-array/) | [C++](./C++/find-the-median-of-the-uniqueness-array.cpp) [Python](./Python/find-the-median-of-the-uniqueness-array.py) | _O(nlogn)_ | _O(n)_ | Hard | | Binary Search, Two Pointers, Sliding Window |
3135 | [Equalize Strings by Adding or Removing Characters at Ends](https://leetcode.com/problems/equalize-strings-by-adding-or-removing-characters-at-ends/) | [C++](./C++/equalize-strings-by-adding-or-removing-characters-at-ends.cpp) [Python](./Python/equalize-strings-by-adding-or-removing-characters-at-ends.py) | _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](https://leetcode.com/problems/find-products-of-elements-of-big-array/) | [C++](./C++/find-products-of-elements-of-big-array.cpp) [Python](./Python/find-products-of-elements-of-big-array.py) | _O(q * (logr)^2)_ | _O(1)_ | Hard | | Binary Search, Combinatorics, Bitmasks, Fast Exponentiation
3231 | [Minimum Number of Increasing Subsequence to Be Removed](https://leetcode.com/problems/minimum-number-of-increasing-subsequence-to-be-removed/) | [C++](./C++/minimum-number-of-increasing-subsequence-to-be-removed.cpp) [Python](./Python/minimum-number-of-increasing-subsequence-to-be-removed.py) | _O(nlogn)_ | _O(n)_ | Hard | 🔒, variant of [Longest Increasing Subsequence](https://leetcode.com/problems/longest-increasing-subsequence/) | Binary Search
3233 | [Find the Count of Numbers Which Are Not Special](https://leetcode.com/problems/find-the-count-of-numbers-which-are-not-special/) | [C++](./C++/find-the-count-of-numbers-which-are-not-special.cpp) [Python](./Python/find-the-count-of-numbers-which-are-not-special.py) | 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](https://leetcode.com/problems/maximize-score-of-numbers-in-ranges/) | [C++](./C++/maximize-score-of-numbers-in-ranges.cpp) [Python](./Python/maximize-score-of-numbers-in-ranges.py) | _O(nlogr)_ | _O(1)_ | Medium | | Binary Search, Greedy
3288 | [Length of the Longest Increasing Path](https://leetcode.com/problems/length-of-the-longest-increasing-path/) | [C++](./C++/length-of-the-longest-increasing-path.cpp) [Python](./Python/length-of-the-longest-increasing-path.py) | _O(nlogn)_ | _O(n)_ | Hard | | Sort, Binary Search, Longest Increasing Subsequence
3296 | [Minimum Number of Seconds to Make Mountain Height Zero](https://leetcode.com/problems/minimum-number-of-seconds-to-make-mountain-height-zero/) | [C++](./C++/minimum-number-of-seconds-to-make-mountain-height-zero.cpp) [Python](./Python/minimum-number-of-seconds-to-make-mountain-height-zero.py) | _O(nlogr)_ | _O(1)_ | Medium | | Binary Search, Quadratic Equation, Heap
3356 | [Zero Array Transformation II](https://leetcode.com/problems/zero-array-transformation-ii/) | [C++](./C++/zero-array-transformation-ii.cpp) [Python](./Python/zero-array-transformation-ii.py) | _O((n + q) * logn)_   | _O(n)_        | Medium         | | Binary Search, Line Sweep
3357 | [Minimize the Maximum Adjacent Element Difference](https://leetcode.com/problems/minimize-the-maximum-adjacent-element-difference/) | [C++](./C++/minimize-the-maximum-adjacent-element-difference.cpp) [Python](./Python/minimize-the-maximum-adjacent-element-difference.py) | _O(nlogr)_   | _O(1)_        | Hard         | | Binary Search
3398 | [Smallest Substring With Identical Characters I](https://leetcode.com/problems/smallest-substring-with-identical-characters-i/) | [C++](./C++/smallest-substring-with-identical-characters-i.cpp) [Python](./Python/smallest-substring-with-identical-characters-i.py) | _O(nlogn)_   | _O(1)_        | Hard         | | Binary Search, Greedy
3399 | [Smallest Substring With Identical Characters II](https://leetcode.com/problems/smallest-substring-with-identical-characters-ii/) | [C++](./C++/smallest-substring-with-identical-characters-ii.cpp) [Python](./Python/smallest-substring-with-identical-characters-ii.py) | _O(nlogn)_   | _O(1)_        | Hard         | | Binary Search, Greedy
3449 | [Maximize the Minimum Game Score](https://leetcode.com/problems/maximize-the-minimum-game-score/) | [C++](./C++/maximize-the-minimum-game-score.cpp) [Python](./Python/maximize-the-minimum-game-score.py) | _O(n * log(m * r))_   | _O(1)_        | Hard         | | Binary Search, Greedy
3464 | [Maximize the Distance Between Points on a Square](https://leetcode.com/problems/maximize-the-distance-between-points-on-a-square/) | [C++](./C++/maximize-the-distance-between-points-on-a-square.cpp) [Python](./Python/maximize-the-distance-between-points-on-a-square.py) | _O(nlogn + nlogs)_   | _O(n)_        | Hard         | | Sort, Binary Search, Greedy, Two Pointers, Sliding Window
3477 | [Fruits Into Baskets II](https://leetcode.com/problems/fruits-into-baskets-ii/) | [C++](./C++/fruits-into-baskets-ii.cpp) [Python](./Python/fruits-into-baskets-ii.py) | _O(nlogn)_   | _O(n)_        | Easy         | | Segment Tree, Binary Search, Brute Force
3479 | [Fruits Into Baskets III](https://leetcode.com/problems/fruits-into-baskets-iii/) | [C++](./C++/fruits-into-baskets-iii.cpp) [Python](./Python/fruits-into-baskets-iii.py) | _O(nlogn)_   | _O(n)_        | Medium         | | Segment Tree, Binary Search
3520 | [Minimum Threshold for Inversion Pairs Count](https://leetcode.com/problems/minimum-threshold-for-inversion-pairs-count/)|[C++](./C++/minimum-threshold-for-inversion-pairs-count.cpp) [Python](./Python/minimum-threshold-for-inversion-pairs-count.py) | _O(nlogn * logr)_      | _O(n)_          | Medium         | 🔒 | Binary Search, Sorted List, Ordered Set
3605 | [Minimum Stability Factor of Array](https://leetcode.com/problems/minimum-stability-factor-of-array/)|[C++](./C++/minimum-stability-factor-of-array.cpp) [Python](./Python/minimum-stability-factor-of-array.py) | _O(nlogn * logr)_      | _O(nlogn)_          | Hard         | | Number Theory, Binary Search, RMQ, Sparse Table, Greedy
3722 | [Lexicographically Smallest String After Reverse](https://leetcode.com/problems/lexicographically-smallest-string-after-reverse/) | [C++](./C++/lexicographically-smallest-string-after-reverse.cpp) [Python](./Python/lexicographically-smallest-string-after-reverse.py) | _O(nlogn)_ | _O(n)_ | Medium         | | String, Brute Force, Binary Search, `Rabin-Karp Algorithm`, Rolling Hash
3733 | [Minimum Time to Complete All Deliveries](https://leetcode.com/problems/minimum-time-to-complete-all-deliveries/)|[C++](./C++/minimum-time-to-complete-all-deliveries.cpp) [Python](./Python/minimum-time-to-complete-all-deliveries.py) | _O(logr + logd)_      | _O(1)_          | Medium         | | Binary Search
3735 | [Lexicographically Smallest String After Reverse II](https://leetcode.com/problems/lexicographically-smallest-string-after-reverse-ii/)|[C++](./C++/lexicographically-smallest-string-after-reverse-ii.cpp) [Python](./Python/lexicographically-smallest-string-after-reverse-ii.py) | _O(nlogn)_      | _O(n)_          | Hard         | 🔒 | Binary Search, `Rabin-Karp Algorithm`, Rolling Hash
3771 | [Total Score of Dungeon Runs](https://leetcode.com/problems/total-score-of-dungeon-runs/)|[C++](./C++/total-score-of-dungeon-runs.cpp) [Python](./Python/total-score-of-dungeon-runs.py) | _O(nlogn)_      | _O(n)_          | Medium         | | Prefix Sum, Binary Search
3807 | [Minimum Cost to Repair Edges to Traverse a Graph](https://leetcode.com/problems/minimum-cost-to-repair-edges-to-traverse-a-graph/)|[C++](./C++/minimum-cost-to-repair-edges-to-traverse-a-graph.cpp) [Python](./Python/minimum-cost-to-repair-edges-to-traverse-a-graph.py) | _O((n + m) * logr)_      | _O(n + m)_          | Medium         | 🔒 | Binary Search, BFS
3824 | [Minimum K to Reduce Array Within Limit](https://leetcode.com/problems/minimum-k-to-reduce-array-within-limit/)|[C++](./C++/minimum-k-to-reduce-array-within-limit.cpp) [Python](./Python/minimum-k-to-reduce-array-within-limit.py) | _O(nlogn + nlogr)_      | _O(1)_          | Medium         | | Binary Search
3825 | [Longest Strictly Increasing Subsequence With Non-Zero Bitwise AND](https://leetcode.com/problems/longest-strictly-increasing-subsequence-with-non-zero-bitwise-and/)|[C++](./C++/longest-strictly-increasing-subsequence-with-non-zero-bitwise-and.cpp) [Python](./Python/longest-strictly-increasing-subsequence-with-non-zero-bitwise-and.py) | _O(logr * nlogn)_      | _O(n)_          | Medium         | | Bitmasks, LIS, Longest Increasing Subsequence, Binary Search
3826 | [Minimum Partition Score](https://leetcode.com/problems/minimum-partition-score/)|[C++](./C++/minimum-partition-score.cpp) [Python](./Python/minimum-partition-score.py) | _O(nlogn + nlogr)_      | _O(n)_          | Hard         | | Prefix Sum, DP, Convex Hull Trick, WQS Binary Search, Alien Trick
3893 | [Maximum Team Size with Overlapping Intervals](https://leetcode.com/problems/maximum-team-size-with-overlapping-intervals/)|[C++](./C++/maximum-team-size-with-overlapping-intervals.cpp) [Python](./Python/maximum-team-size-with-overlapping-intervals.py) | _O(nlogn)_      | _O(n)_          | Medium         | 🔒 | Sort, Binary Search
3911 | [K-th Smallest Remaining Even Integer in Subarray Queries](https://leetcode.com/problems/k-th-smallest-remaining-even-integer-in-subarray-queries/)|[C++](./C++/k-th-smallest-remaining-even-integer-in-subarray-queries.cpp) [Python](./Python/k-th-smallest-remaining-even-integer-in-subarray-queries.py) | _O(n + qlogn)_      | _O(n)_          | Hard         | | Prefix Sum, Binary Search
3920 | [Maximize Fixed Points After Deletions](https://leetcode.com/problems/maximize-fixed-points-after-deletions/) | [C++](./C++/maximize-fixed-points-after-deletions.cpp) [Python](./Python/maximize-fixed-points-after-deletions.py) | _O(nlogn)_ | _O(n)_ | Hard | | Sort, Binary Search, Longest Increasing Subsequence
3924 | [Minimum Threshold Path With Limited Heavy Edges](https://leetcode.com/problems/minimum-threshold-path-with-limited-heavy-edges/) | [C++](./C++/minimum-threshold-path-with-limited-heavy-edges.cpp) [Python](./Python/minimum-threshold-path-with-limited-heavy-edges.py) | _O((n + e) * loge)_ | _O(n + e)_ | Hard | | Binary Search, 0-1 BFS, Deque
3929 | [Minimum Partition Score II](https://leetcode.com/problems/minimum-partition-score-ii/)|[C++](./C++/minimum-partition-score-ii.cpp) [Python](./Python/minimum-partition-score-ii.py) | _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](https://leetcode.com/problems/count-k-th-roots-in-a-range/)|[C++](./C++/count-k-th-roots-in-a-range.cpp) [Python](./Python/count-k-th-roots-in-a-range.py) | _O(logr * logk)_      | _O(1)_          | Medium         | | Binary Search, Fast Exponentiation
3934 | [Smallest Unique Subarray](https://leetcode.com/problems/smallest-unique-subarray/) | [C++](./C++/smallest-unique-subarray.cpp) [Python](./Python/smallest-unique-subarray.py) | _O(nlogn)_ | _O(n)_ | Hard | | Binary Search, `Rabin-Karp Algorithm`, Rolling Hash
3956 | [Maximum Sum of M Non-Overlapping Subarrays I](https://leetcode.com/problems/maximum-sum-of-m-non-overlapping-subarrays-i/)|[C++](./C++/maximum-sum-of-m-non-overlapping-subarrays-i.cpp) [Python](./Python/maximum-sum-of-m-non-overlapping-subarrays-i.py) | _O(nlogr)_      | _O(n)_          | Hard         | | Prefix Sum, DP, Mono Deque, WQS Binary Search, Alien Trick
3957 | [Maximum Sum of M Non-Overlapping Subarrays II](https://leetcode.com/problems/maximum-sum-of-m-non-overlapping-subarrays-ii/)|[C++](./C++/maximum-sum-of-m-non-overlapping-subarrays-ii.cpp) [Python](./Python/maximum-sum-of-m-non-overlapping-subarrays-ii.py) | _O(nlogr)_      | _O(n)_          | Hard         | | Prefix Sum, DP, Mono Deque, WQS Binary Search, Alien Trick
3971 | [Maximum Total Value](https://leetcode.com/problems/maximum-total-value/)|[C++](./C++/maximum-total-value.cpp) [Python](./Python/maximum-total-value.py) | _O(nlogr)_      | _O(1)_          | Hard         | | Binary Search



    **[⬆️ Back to Top](#algorithms)**



## Binary Search Tree
|  #  | Title           |  Solution       |  Time           | Space           | Difficulty    | Tag          | Note| 
|-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------|-----|
3072 | [Distribute Elements Into Two Arrays II](https://leetcode.com/problems/distribute-elements-into-two-arrays-ii/) | [C++](./C++/distribute-elements-into-two-arrays-ii.cpp) [Python](./Python/distribute-elements-into-two-arrays-ii.py) | _O(nlogn)_ | _O(n)_ | Hard | | Sorted List, Ordered Set
3073 | [Maximum Increasing Triplet Value](https://leetcode.com/problems/maximum-increasing-triplet-value/) | [C++](./C++/maximum-increasing-triplet-value.cpp) [Python](./Python/maximum-increasing-triplet-value.py) | _O(nlogn)_ | _O(n)_ | Medium | 🔒 | Sorted List, BST, Prefix Sum
3161 | [Block Placement Queries](https://leetcode.com/problems/block-placement-queries/) | [C++](./C++/block-placement-queries.cpp) [Python](./Python/block-placement-queries.py) | _O(qlogq)_ | _O(q)_ | Hard | | Sorted List, BST, BIT, Fenwick Tree, Segment Tree
3165 | [Maximum Sum of Subsequence With Non-adjacent Elements](https://leetcode.com/problems/maximum-sum-of-subsequence-with-non-adjacent-elements/) | [C++](./C++/maximum-sum-of-subsequence-with-non-adjacent-elements.cpp) [Python](./Python/maximum-sum-of-subsequence-with-non-adjacent-elements.py) | _O(n + qlogn)_ | _O(n)_ | Hard | | Segment Tree
3526 | [Range XOR Queries with Subarray Reversals](https://leetcode.com/problems/range-xor-queries-with-subarray-reversals/) | [C++](./C++/range-xor-queries-with-subarray-reversals.cpp) [Python](./Python/range-xor-queries-with-subarray-reversals.py) | _O(n + qlogn)_ | _O(n)_ | Hard | 🔒 | Treap
3930 | [Power Update After K-th Largest Insertion II](https://leetcode.com/problems/power-update-after-k-th-largest-insertion-ii/) | [C++](./C++/power-update-after-k-th-largest-insertion-ii.cpp) [Python](./Python/power-update-after-k-th-largest-insertion-ii.py) | _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](https://leetcode.com/problems/power-update-after-k-th-largest-insertion-i/) | [C++](./C++/power-update-after-k-th-largest-insertion-ii.cpp) [Python](./Python/power-update-after-k-th-largest-insertion-i.py) | _O((n + q) * log(n * q) + q * logr)_ | _O(n + q)_ | Medium | 🔒 | Sorted List, Ordered Set, Sort, Coordinate Compression, BIT, Fenwick Tree, Fast Exponentiation



    **[⬆️ Back to Top](#algorithms)**



## Breadth-First Search
|  #  | Title           |  Solution       |  Time           | Space           | Difficulty    | Tag          | Note| 
|-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------|-----|
3157 | [Find the Level of Tree with Minimum Sum](https://leetcode.com/problems/find-the-level-of-tree-with-minimum-sum/)| [C++](./C++/find-the-level-of-tree-with-minimum-sum.cpp) [Python](./Python/find-the-level-of-tree-with-minimum-sum.py)| _O(n)_ | _O(w)_ | Medium | 🔒 | BFS |
3286 | [Find a Safe Walk Through a Grid](https://leetcode.com/problems/find-a-safe-walk-through-a-grid/)| [C++](./C++/find-a-safe-walk-through-a-grid.cpp) [Python](./Python/find-a-safe-walk-through-a-grid.py)| _O(m * n)_ | _O(m * n)_ | Medium | variant of [Minimum Obstacle Removal to Reach Corner](https://leetcode.com/problems/minimum-obstacle-removal-to-reach-corner/) | 0-1 BFS, Deque |
3373 | [Maximize the Number of Target Nodes After Connecting Trees II](https://leetcode.com/problems/maximize-the-number-of-target-nodes-after-connecting-trees-ii/) | [C++](./C++/maximize-the-number-of-target-nodes-after-connecting-trees-ii.cpp) [Python](./Python/maximize-the-number-of-target-nodes-after-connecting-trees-ii.py) | _O(n + m)_ | _O(n + m)_ | Hard | | BFS
3528 | [Unit Conversion I](https://leetcode.com/problems/unit-conversion-i/) | [C++](./C++/unit-conversion-i.cpp) [Python](./Python/unit-conversion-i.py) | _O(n)_ | _O(n)_ | Medium | | BFS
3535 | [Unit Conversion II](https://leetcode.com/problems/unit-conversion-ii/) | [C++](./C++/unit-conversion-ii.cpp) [Python](./Python/unit-conversion-ii.py) | _O(n + qlogm)_ | _O(n)_ | Medium | 🔒 | BFS, Fast Exponentiation
3552 | [Grid Teleportation Traversal](https://leetcode.com/problems/grid-teleportation-traversal/) | [C++](./C++/grid-teleportation-traversal.cpp) [Python](./Python/grid-teleportation-traversal.py) | _O(m * n)_ | _O(m * n)_ | Medium |  | 0-1 BFS, Deque
3568 | [Minimum Moves to Clean the Classroom](https://leetcode.com/problems/minimum-moves-to-clean-the-classroom/) | [C++](./C++/minimum-moves-to-clean-the-classroom.cpp) [Python](./Python/minimum-moves-to-clean-the-classroom.py) | _O(m * n * 2^l)_ | _O(m * n * 2^l)_ | Medium |  | BFS, Bitmasks
3619 | [Count Islands With Total Value Divisible by K](https://leetcode.com/problems/count-islands-with-total-value-divisible-by-k/)| [C++](./C++/count-islands-with-total-value-divisible-by-k.cpp) [Python](./Python/count-islands-with-total-value-divisible-by-k.py)| _O(m * n)_ | _O(m + n)_ | Medium |  | BFS, Flood Fill |
3629 | [Minimum Jumps to Reach End via Prime Teleportation](https://leetcode.com/problems/minimum-jumps-to-reach-end-via-prime-teleportation/) | [C++](./C++/minimum-jumps-to-reach-end-via-prime-teleportation.cpp) [Python](./Python/minimum-jumps-to-reach-end-via-prime-teleportation.py) | precompute: _O(r)_runtime: _O(nlogr)_ | _O(r + nlogr)_ | Medium |  | Number Theory, `Linear Sieve of Eratosthenes`, BFS
3690 | [Split and Merge Array Transformation](https://leetcode.com/problems/split-and-merge-array-transformation/) | [C++](./C++/split-and-merge-array-transformation.cpp) [Python](./Python/split-and-merge-array-transformation.py) | _O(n^4 * n!)_ | _O(n * n!)_ | Medium |  | BFS
3695 | [Maximize Alternating Sum Using Swaps](https://leetcode.com/problems/maximize-alternating-sum-using-swaps/) | [C++](./C++/maximize-alternating-sum-using-swaps.cpp) [Python](./Python/maximize-alternating-sum-using-swaps.py) | _O(n + s)_ | _O(n + s)_ | Hard |  | BFS, Flood Fill, Quick Select
3786 | [Total Sum of Interaction Cost in Tree Groups](https://leetcode.com/problems/total-sum-of-interaction-cost-in-tree-groups/)| [C++](./C++/total-sum-of-interaction-cost-in-tree-groups.cpp) [Python](./Python/total-sum-of-interaction-cost-in-tree-groups.py)| _O(nlogn)_ | _O(n)_ | Hard | | BFS, DFS, Small-to-Large Merging |
3787 | [Find Diameter Endpoints of a Tree](https://leetcode.com/problems/find-diameter-endpoints-of-a-tree/)| [C++](./C++/find-diameter-endpoints-of-a-tree.cpp) [Python](./Python/find-diameter-endpoints-of-a-tree.py)| _O(n)_ | _O(n)_ | Medium | 🔒 | BFS, Tree Diameter |
3820 | [Pythagorean Distance Nodes in a Tree](https://leetcode.com/problems/pythagorean-distance-nodes-in-a-tree/)| [C++](./C++/pythagorean-distance-nodes-in-a-tree.cpp) [Python](./Python/pythagorean-distance-nodes-in-a-tree.py)| _O(n)_ | _O(n)_ | Medium |  | BFS |
3831 | [Median of a Binary Search Tree Level](https://leetcode.com/problems/median-of-a-binary-search-tree-level/)| [C++](./C++/median-of-a-binary-search-tree-level.cpp) [Python](./Python/median-of-a-binary-search-tree-level.py)| _O(n)_ | _O(n)_ | Medium | 🔒 | BFS |
3902 | [Zigzag Level Sum of Binary Tree](https://leetcode.com/problems/zigzag-level-sum-of-binary-tree/)| [C++](./C++/zigzag-level-sum-of-binary-tree.cpp) [Python](./Python/zigzag-level-sum-of-binary-tree.py)| _O(n)_ | _O(w)_ | Hard | 🔒 | BFS |
3905 | [Multi Source Flood Fill](https://leetcode.com/problems/multi-source-flood-fill/)| [C++](./C++/multi-source-flood-fill.cpp) [Python](./Python/multi-source-flood-fill.py)| _O(n * m)_ | _O(n * m)_ | Medium | | Sort, BFS, Flood Fill |
3923 | [Minimum Generations to Target Point](https://leetcode.com/problems/minimum-generations-to-target-point/)| [C++](./C++/minimum-generations-to-target-point.cpp) [Python](./Python/minimum-generations-to-target-point.py)| _O(7^6)_ | _O(7^3)_ | Medium | | BFS |
3991 | [Sort Array Using Prefix Reversals](https://leetcode.com/problems/sort-array-using-prefix-reversals/)| [C++](./C++/sort-array-using-prefix-reversals.cpp) [Python](./Python/sort-array-using-prefix-reversals.py)| _O(n! * n * m)_ | _O(n! * n)_ | Medium | 🔒 | BFS, Bi-BFS |



    **[⬆️ Back to Top](#algorithms)**



## Depth-First Search
|  #  | Title           |  Solution       |  Time           | Space           | Difficulty    | Tag          | Note| 
|-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------|-----|
3004 | [Maximum Subtree of the Same Color](https://leetcode.com/problems/maximum-subtree-of-the-same-color/)| [C++](./C++/maximum-subtree-of-the-same-color.cpp) [Python](./Python/maximum-subtree-of-the-same-color.py)| _O(n)_ | _O(h)_ | Medium | 🔒 | DFS |
3067 | [Count Pairs of Connectable Servers in a Weighted Tree Network](https://leetcode.com/problems/count-pairs-of-connectable-servers-in-a-weighted-tree-network/)| [C++](./C++/count-pairs-of-connectable-servers-in-a-weighted-tree-network.cpp) [Python](./Python/count-pairs-of-connectable-servers-in-a-weighted-tree-network.py)| _O(n^2)_ | _O(n)_ | Medium | | DFS, BFS |
3203 | [Find Minimum Diameter After Merging Two Trees](https://leetcode.com/problems/find-minimum-diameter-after-merging-two-trees/)| [C++](./C++/find-minimum-diameter-after-merging-two-trees.cpp) [Python](./Python/find-minimum-diameter-after-merging-two-trees.py)| _O(n + m)_ | _O(n + m)_ | Hard | variant of [Tree Diameter](https://leetcode.com/problems/tree-diameter/) | DFS, BFS, Tree DP, Tree Diameter |
3249 | [Count the Number of Good Nodes](https://leetcode.com/problems/count-the-number-of-good-nodes/)| [C++](./C++/count-the-number-of-good-nodes.cpp) [Python](./Python/count-the-number-of-good-nodes.py)| _O(n)_ | _O(h)_ | Medium |  | DFS |
3319 | [K-th Largest Perfect Subtree Size in Binary Tree](https://leetcode.com/problems/k-th-largest-perfect-subtree-size-in-binary-tree/)| [C++](./C++/k-th-largest-perfect-subtree-size-in-binary-tree.cpp) [Python](./Python/k-th-largest-perfect-subtree-size-in-binary-tree.py)| _O(n)_ | _O(n)_ | Medium |  | DFS, Quick Select |
3327 | [Check if DFS Strings Are Palindromes](https://leetcode.com/problems/check-if-dfs-strings-are-palindromes/)| [C++](./C++/check-if-dfs-strings-are-palindromes.cpp) [Python](./Python/check-if-dfs-strings-are-palindromes.py)| _O(n)_ | _O(n)_ | Hard |  | DFS, `Manacher's Algorithm` |
3331 | [Find Subtree Sizes After Changes](https://leetcode.com/problems/find-subtree-sizes-after-changes/)| [C++](./C++/find-subtree-sizes-after-changes.cpp) [Python](./Python/find-subtree-sizes-after-changes.py)| _O(n)_ | _O(n)_ | Medium |  | DFS, Hash Table |
3367 | [Maximize Sum of Weights after Edge Removals](https://leetcode.com/problems/maximize-sum-of-weights-after-edge-removals/)| [C++](./C++/maximize-sum-of-weights-after-edge-removals.cpp) [Python](./Python/maximize-sum-of-weights-after-edge-removals.py)| _O(n)_ | _O(n)_ | Hard |  | DFS, Quick Select |
3590 | [Kth Smallest Path XOR Sum](https://leetcode.com/problems/kth-smallest-path-xor-sum/)| [C++](./C++/kth-smallest-path-xor-sum.cpp) [Python](./Python/kth-smallest-path-xor-sum.py)| _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](https://leetcode.com/problems/minimum-increments-to-equalize-leaf-paths/)| [C++](./C++/minimum-increments-to-equalize-leaf-paths.cpp) [Python](./Python/minimum-increments-to-equalize-leaf-paths.py)| _O(n)_ | _O(n)_ | Medium |  | DFS |
3607 | [Power Grid Maintenance](https://leetcode.com/problems/power-grid-maintenance/)| [C++](./C++/power-grid-maintenance.cpp) [Python](./Python/power-grid-maintenance.py)| _O(c + n + q)_ | _O(c + n)_ | Medium |  | DFS, Flood Fill, Sort |
4015 | [Weighted Sum of a Tree](https://leetcode.com/problems/weighted-sum-of-a-tree/)| [C++](./C++/weighted-sum-of-a-tree.cpp) [Python](./Python/weighted-sum-of-a-tree.py)| _O(n)_ | _O(n)_ | Medium |  | DFS, Tree DP |
4018 | [Total Sum of Interaction Cost in Tree Groups II](https://leetcode.com/problems/total-sum-of-interaction-cost-in-tree-groups-ii/)| [C++](./C++/total-sum-of-interaction-cost-in-tree-groups-ii.cpp) [Python](./Python/total-sum-of-interaction-cost-in-tree-groups-ii.py)| _O(nlogn)_ | _O(n)_ | Hard | 🔒 | DFS, Small-to-Large Merging |



    **[⬆️ Back to Top](#algorithms)**



## Backtracking
|  #  | Title           |  Solution       |  Time           | Space           | Difficulty    | Tag          | Note| 
|-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------|-----|
3211 | [Generate Binary Strings Without Adjacent Zeros](https://leetcode.com/problems/generate-binary-strings-without-adjacent-zeros/) | [C++](./C++/generate-binary-strings-without-adjacent-zeros.cpp) [Python](./Python/generate-binary-strings-without-adjacent-zeros.py) | _O(n * 2^n)_   | _O(n)_        | Medium         | | Backtracking, BFS
3437 | [Permutations III](https://leetcode.com/problems/permutations-iii/) | [C++](./C++/permutations-iii.cpp) [Python](./Python/permutations-iii.py) | _O(n * n!)_   | _O(n)_        | Medium         | 🔒 | Backtracking, Bitmasks
3565 | [Sequential Grid Path Cover](https://leetcode.com/problems/sequential-grid-path-cover/) | [C++](./C++/sequential-grid-path-cover.cpp) [Python](./Python/sequential-grid-path-cover.py) | _O(m * n * 3^(m * n))_   | _O(m * n)_        | Medium         | 🔒 | Backtracking
3669 | [Balanced K-Factor Decomposition](https://leetcode.com/problems/balanced-k-factor-decomposition/) | [C++](./C++/balanced-k-factor-decomposition.cpp) [Python](./Python/balanced-k-factor-decomposition.py) | precompute: _O(rlogr)_runtime: _O(k * (logn)^(k - 1))_   | _O(rlogr)_        | Medium         | | Backtracking, Number Theory
3955 | [Valid Binary Strings With Cost Limit](https://leetcode.com/problems/valid-binary-strings-with-cost-limit/) | [C++](./C++/valid-binary-strings-with-cost-limit.cpp) [Python](./Python/valid-binary-strings-with-cost-limit.py) | _O(n * 2^n)_   | _O(n)_        | Medium         | | Backtracking, Bitmasks



    **[⬆️ Back to Top](#algorithms)**



## Dynamic Programming
|  #  | Title           |  Solution       |  Time           | Space           | Difficulty    | Tag          | Note| 
|-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------|-----|
3018 | [Maximum Number of Removal Queries That Can Be Processed I](https://leetcode.com/problems/maximum-number-of-removal-queries-that-can-be-processed-i/) | [C++](./C++/maximum-number-of-removal-queries-that-can-be-processed-i.cpp) [Python](./Python/maximum-number-of-removal-queries-that-can-be-processed-i.py) | _O(n^2)_ | _O(n^2)_ | Hard | 🔒 | DP
3020 | [Find the Maximum Number of Elements in Subset](https://leetcode.com/problems/find-the-maximum-number-of-elements-in-subset/) | [C++](./C++/find-the-maximum-number-of-elements-in-subset.cpp) [Python](./Python/find-the-maximum-number-of-elements-in-subset.py) | _O(n)_ | _O(n)_ | Medium || Freq Table, DP
3040 | [Maximum Number of Operations With the Same Score II](https://leetcode.com/problems/maximum-number-of-operations-with-the-same-score-ii/) | [C++](./C++/maximum-number-of-operations-with-the-same-score-ii.cpp) [Python](./Python/maximum-number-of-operations-with-the-same-score-ii.py) | _O(n^2)_ | _O(n^2)_ | Medium | | Memoization
3041 | [Maximize Consecutive Elements in an Array After Modification](https://leetcode.com/problems/maximize-consecutive-elements-in-an-array-after-modification/) | [C++](./C++/maximize-consecutive-elements-in-an-array-after-modification.cpp) [Python](./Python/maximize-consecutive-elements-in-an-array-after-modification.py) | _O(nlogn)_ | _O(1)_ | Hard | | Sort, DP
3077 | [Maximum Strength of K Disjoint Subarrays](https://leetcode.com/problems/maximum-strength-of-k-disjoint-subarrays/) | [C++](./C++/maximum-strength-of-k-disjoint-subarrays.cpp) [Python](./Python/maximum-strength-of-k-disjoint-subarrays.py) | _O(k * n)_ | _O(n)_ | Hard | | DP, Greedy, `Kadane's Algorithm`
3082 | [Find the Sum of the Power of All Subsequences](https://leetcode.com/problems/find-the-sum-of-the-power-of-all-subsequences/) | [C++](./C++/find-the-sum-of-the-power-of-all-subsequences.cpp) [Python](./Python/find-the-sum-of-the-power-of-all-subsequences.py) | _O(n * k)_ | _O(k)_ | Hard | | DP, Combinatorics
3098 | [Find the Sum of Subsequence Powers](https://leetcode.com/problems/find-the-sum-of-subsequence-powers/) | [C++](./C++/find-the-sum-of-subsequence-powers.cpp) [Python](./Python/find-the-sum-of-subsequence-powers.py) | _O(n^3 * k)_ | _O(n^2)_ | Hard | | DP, Prefix Sum, Two Pointers
3101 | [Count Alternating Subarrays](https://leetcode.com/problems/count-alternating-subarrays/) | [C++](./C++/count-alternating-subarrays.cpp) [Python](./Python/count-alternating-subarrays.py) | _O(n)_ | _O(1)_ | Medium | | DP
3117 | [Minimum Sum of Values by Dividing Array](https://leetcode.com/problems/minimum-sum-of-values-by-dividing-array/) | [C++](./C++/minimum-sum-of-values-by-dividing-array.cpp) [Python](./Python/minimum-sum-of-values-by-dividing-array.py) | _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](https://leetcode.com/problems/minimum-number-of-operations-to-satisfy-conditions/) | [C++](./C++/minimum-number-of-operations-to-satisfy-conditions.cpp) [Python](./Python/minimum-number-of-operations-to-satisfy-conditions.py) | _O(n * (m + 10))_ | _O(10)_ | Medium | | DP
3129 | [Find All Possible Stable Binary Arrays I](https://leetcode.com/problems/find-all-possible-stable-binary-arrays-i/) | [C++](./C++/find-all-possible-stable-binary-arrays-i.cpp) [Python](./Python/find-all-possible-stable-binary-arrays-i.py) | _O(n * m)_ | _O(n * m)_ | Medium | | DP
3130 | [Find All Possible Stable Binary Arrays II](https://leetcode.com/problems/find-all-possible-stable-binary-arrays-ii/) | [C++](./C++/find-all-possible-stable-binary-arrays-ii.cpp) [Python](./Python/find-all-possible-stable-binary-arrays-ii.py) | _O(n * m)_ | _O(n * m)_ | Hard | | DP
3141 | [Maximum Hamming Distances](https://leetcode.com/problems/maximum-hamming-distances/)| [C++](./C++/maximum-hamming-distances.cpp) [Python](./Python/maximum-hamming-distances.py)| _O(m * 2^m)_ | _O(2^m)_ | Hard | 🔒 | Bitmasks, BFS, Knapsack DP |
3144 | [Minimum Substring Partition of Equal Character Frequency](https://leetcode.com/problems/minimum-substring-partition-of-equal-character-frequency/) | [C++](./C++/minimum-substring-partition-of-equal-character-frequency.cpp) [Python](./Python/minimum-substring-partition-of-equal-character-frequency.py) | _O(n * (n + 26))_ | _O(n + 26)_ | Medium | | DP, Freq Table
3148 | [Maximum Difference Score in a Grid](https://leetcode.com/problems/maximum-difference-score-in-a-grid/) | [C++](./C++/maximum-difference-score-in-a-grid.cpp) [Python](./Python/maximum-difference-score-in-a-grid.py) | _O(m * n)_ | _O(1)_ | Medium | | DP
3149 | [Find the Minimum Cost Array Permutation](https://leetcode.com/problems/find-the-minimum-cost-array-permutation/) | [C++](./C++/find-the-minimum-cost-array-permutation.cpp) [Python](./Python/find-the-minimum-cost-array-permutation.py) | _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](https://leetcode.com/problems/find-the-maximum-length-of-a-good-subsequence-i/) | [C++](./C++/find-the-maximum-length-of-a-good-subsequence-i.cpp) [Python](./Python/find-the-maximum-length-of-a-good-subsequence-i.py) | _O(n * k)_ | _O(n * k)_ | Medium | | DP
3177 | [Find the Maximum Length of a Good Subsequence II](https://leetcode.com/problems/find-the-maximum-length-of-a-good-subsequence-ii/) | [C++](./C++/find-the-maximum-length-of-a-good-subsequence-ii.cpp) [Python](./Python/find-the-maximum-length-of-a-good-subsequence-ii.py) | _O(n * k)_ | _O(n * k)_ | Hard | | DP
3180 | [Maximum Total Reward Using Operations I](https://leetcode.com/problems/maximum-total-reward-using-operations-i/) | [C++](./C++/maximum-total-reward-using-operations-i.cpp) [Python](./Python/maximum-total-reward-using-operations-i.py) | _O(n * k)_ | _O(n * k)_ | Medium | | Sort, DP, Bitset
3181 | [Maximum Total Reward Using Operations II](https://leetcode.com/problems/maximum-total-reward-using-operations-ii/) | [C++](./C++/maximum-total-reward-using-operations-ii.cpp) [Python](./Python/maximum-total-reward-using-operations-ii.py) | _O(n * k)_ | _O(n * k)_ | Hard | | Sort, DP, Bitset
3186 | [Maximum Total Damage With Spell Casting](https://leetcode.com/problems/maximum-total-damage-with-spell-casting/) | [C++](./C++/maximum-total-damage-with-spell-casting.cpp) [Python](./Python/maximum-total-damage-with-spell-casting.py) | _O(nlogn)_ | _O(n)_ | Medium | | Sort, DP, Two Pointers, Sliding window, Deque
3193 | [Count the Number of Inversions](https://leetcode.com/problems/count-the-number-of-inversions/) | [C++](./C++/count-the-number-of-inversions.cpp) [Python](./Python/count-the-number-of-inversions.py) | _O(n * k)_ | _O(n + k)_ | Hard | variant of [K Inverse Pairs Array](https://leetcode.com/problems/k-inverse-pairs-array/) | Knapsack DP, Combinatorics, Sliding Window, Two Pointers
3196 | [Maximize Total Cost of Alternating Subarrays](https://leetcode.com/problems/maximize-total-cost-of-alternating-subarrays/) | [C++](./C++/maximize-total-cost-of-alternating-subarrays.cpp) [Python](./Python/maximize-total-cost-of-alternating-subarrays.py) | _O(n)_ | _O(1)_ | Medium | | DP
3197 | [Find the Minimum Area to Cover All Ones II](https://leetcode.com/problems/find-the-minimum-area-to-cover-all-ones-ii/) | [C++](./C++/find-the-minimum-area-to-cover-all-ones-ii.cpp) [Python](./Python/find-the-minimum-area-to-cover-all-ones-ii.py) | _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](https://leetcode.com/problems/find-the-maximum-length-of-valid-subsequence-i/) | [C++](./C++/find-the-maximum-length-of-valid-subsequence-i.cpp) [Python](./Python/find-the-maximum-length-of-valid-subsequence-i.py) | _O(n)_ | _O(1)_ | Medium | | Brute Force, DP
3202 | [Find the Maximum Length of Valid Subsequence II](https://leetcode.com/problems/find-the-maximum-length-of-valid-subsequence-ii/) | [C++](./C++/find-the-maximum-length-of-valid-subsequence-ii.cpp) [Python](./Python/find-the-maximum-length-of-valid-subsequence-ii.py) | _O(n * k)_ | _O(k)_ | Medium | | DP
3209 | [Number of Subarrays With AND Value of K](https://leetcode.com/problems/number-of-subarrays-with-and-value-of-k/)| [C++](./C++/number-of-subarrays-with-and-value-of-k.cpp) [Python](./Python/number-of-subarrays-with-and-value-of-k.py) | _O(nlogr)_    | _O(logr)_          | Hard           | variant of [Find Subarray With Bitwise OR Closest to K](https://leetcode.com/problems/find-subarray-with-bitwise-or-closest-to-k/) | DP
3212 | [Count Submatrices With Equal Frequency of X and Y](https://leetcode.com/problems/count-submatrices-with-equal-frequency-of-x-and-y/) | [C++](./C++/count-submatrices-with-equal-frequency-of-x-and-y.cpp) [Python](./Python/count-submatrices-with-equal-frequency-of-x-and-y.py) | _O(n * m)_ | _O(n * m)_ | Medium | | DP
3213 | [Construct String with Minimum Cost](https://leetcode.com/problems/construct-string-with-minimum-cost/) | [C++](./C++/construct-string-with-minimum-cost.cpp) [Python](./Python/construct-string-with-minimum-cost.py) | _O(n^2 + w * l)_ | _O(t)_ | Hard | | DP, Trie
3225 | [Maximum Score From Grid Operations](https://leetcode.com/problems/maximum-score-from-grid-operations/) | [C++](./C++/maximum-score-from-grid-operations.cpp) [Python](./Python/maximum-score-from-grid-operations.py) | _O(n^3)_ | _O(n)_ | Hard | | Prefix Sum, DP
3241 | [Time Taken to Mark All Nodes](https://leetcode.com/problems/time-taken-to-mark-all-nodes/) | [C++](./C++/time-taken-to-mark-all-nodes.cpp) [Python](./Python/time-taken-to-mark-all-nodes.py) | _O(n)_ | _O(n)_ | Hard | | Tree DP, BFS, DFS
3253 | [Construct String with Minimum Cost (Easy)](https://leetcode.com/problems/construct-string-with-minimum-cost-easy/) | [C++](./C++/construct-string-with-minimum-cost-easy.cpp) [Python](./Python/construct-string-with-minimum-cost-easy.py) | _O(n * w * l)_ | _O(l)_ | Medium | 🔒 | DP, Trie
3259 | [Maximum Energy Boost From Two Drinks](https://leetcode.com/problems/maximum-energy-boost-from-two-drinks/) | [C++](./C++/maximum-energy-boost-from-two-drinks.cpp) [Python](./Python/maximum-energy-boost-from-two-drinks.py) | _O(n)_ | _O(1)_ | Medium | | DP
3269 | [Constructing Two Increasing Arrays](https://leetcode.com/problems/constructing-two-increasing-arrays/) | [C++](./C++/constructing-two-increasing-arrays.cpp) [Python](./Python/constructing-two-increasing-arrays.py) | _O(m * n)_ | _O(min(m, n))_ | Hard | 🔒 | DP
3277 | [Maximum XOR Score Subarray Queries](https://leetcode.com/problems/maximum-xor-score-subarray-queries/) | [C++](./C++/maximum-xor-score-subarray-queries.cpp) [Python](./Python/maximum-xor-score-subarray-queries.py) | _O(n^2 + q)_ | _O(n^2)_ | Hard | | DP
3283 | [Maximum Number of Moves to Kill All Pawns](https://leetcode.com/problems/maximum-number-of-moves-to-kill-all-pawns/) | [C++](./C++/maximum-number-of-moves-to-kill-all-pawns.cpp) [Python](./Python/maximum-number-of-moves-to-kill-all-pawns.py) | _O(p^2 * 2^p)_ | _O(p * 2^p)_ | Hard | | BFS, Bitmasks, DP
3287 | [Find the Maximum Sequence Value of Array](https://leetcode.com/problems/find-the-maximum-sequence-value-of-array/) | [C++](./C++/find-the-maximum-sequence-value-of-array.cpp) [Python](./Python/find-the-maximum-sequence-value-of-array.py) | _O(n * r + r^2)_ | _O(r)_ | Hard | | Bitmasks, Prefix Sum, DP
3290 | [Maximum Multiplication Score](https://leetcode.com/problems/maximum-multiplication-score/) | [C++](./C++/maximum-multiplication-score.cpp) [Python](./Python/maximum-multiplication-score.py) | _O(n)_ | _O(1)_ | Medium | | DP
3291 | [Minimum Number of Valid Strings to Form Target I](https://leetcode.com/problems/minimum-number-of-valid-strings-to-form-target-i/)| [C++](./C++/minimum-number-of-valid-strings-to-form-target-i.cpp) [Python](./Python/minimum-number-of-valid-strings-to-form-target-i.py) | _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](https://leetcode.com/problems/minimum-number-of-valid-strings-to-form-target-ii/)| [C++](./C++/minimum-number-of-valid-strings-to-form-target-ii.cpp) [Python](./Python/minimum-number-of-valid-strings-to-form-target-ii.py) | _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](https://leetcode.com/problems/find-the-last-marked-nodes-in-tree/) | [C++](./C++/find-the-last-marked-nodes-in-tree.cpp) [Python](./Python/find-the-last-marked-nodes-in-tree.py) | _O(n)_ | _O(n)_ | Hard | 🔒, variant of [Time Taken to Mark All Nodes](https://leetcode.com/problems/time-taken-to-mark-all-nodes/) | BFS, DFS, Tree DP, Tree Diameter
3316 | [Find Maximum Removals From Source String](https://leetcode.com/problems/find-maximum-removals-from-source-string/) | [C++](./C++/find-maximum-removals-from-source-string.cpp) [Python](./Python/find-maximum-removals-from-source-string.py) | _O(n * m)_ | _O(n + m)_ | Medium | | DP
3320 | [Count The Number of Winning Sequences](https://leetcode.com/problems/count-the-number-of-winning-sequences/) | [C++](./C++/count-the-number-of-winning-sequences.cpp) [Python](./Python/count-the-number-of-winning-sequences.py) | _O(n^2)_ | _O(n)_ | Hard | | DP
3332 | [Maximum Points Tourist Can Earn](https://leetcode.com/problems/maximum-points-tourist-can-earn/) | [C++](./C++/maximum-points-tourist-can-earn.cpp) [Python](./Python/maximum-points-tourist-can-earn.py) | _O(k * n^2)_ | _O(n)_ | Hard | | DP
3333 | [Find the Original Typed String II](https://leetcode.com/problems/find-the-original-typed-string-ii/) | [C++](./C++/find-the-original-typed-string-ii.cpp) [Python](./Python/find-the-original-typed-string-ii.py) | _O(n + k^2)_ | _O(n + k)_ | Hard | | DP
3335 | [Total Characters in String After Transformations I](https://leetcode.com/problems/total-characters-in-string-after-transformations-i/) | [C++](./C++/total-characters-in-string-after-transformations-i.cpp) [Python](./Python/total-characters-in-string-after-transformations-i.py) | precompute: _O(t + 26)_ runtime: _O(n)_ | _O(t + 26)_ | Medium | | DP, Matrix Exponentiation, Precompute
3336 | [Find the Number of Subsequences With Equal GCD](https://leetcode.com/problems/find-the-number-of-subsequences-with-equal-gcd/) | [C++](./C++/find-the-number-of-subsequences-with-equal-gcd.cpp) [Python](./Python/find-the-number-of-subsequences-with-equal-gcd.py) | 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](https://leetcode.com/problems/total-characters-in-string-after-transformations-ii/) | [C++](./C++/total-characters-in-string-after-transformations-ii.cpp) [Python](./Python/total-characters-in-string-after-transformations-ii.py) | _O(n + 26^3 * logt)_ | _O(26^2)_ | Hard | | DP, Matrix Exponentiation
3343 | [Count Number of Balanced Permutations](https://leetcode.com/problems/count-number-of-balanced-permutations/) | [C++](./C++/count-number-of-balanced-permutations.cpp) [Python](./Python/count-number-of-balanced-permutations.py) | _O(n^2)_ | _O(n^2)_ | Hard | | DP, Combinatorics
3351 | [Sum of Good Subsequences](https://leetcode.com/problems/sum-of-good-subsequences/) | [C++](./C++/sum-of-good-subsequences.cpp) [Python](./Python/sum-of-good-subsequences.py) | _O(n)_ | _O(n)_ | Hard | | Freq Table, DP
3352 | [Count K-Reducible Numbers Less Than N](https://leetcode.com/problems/count-k-reducible-numbers-less-than-n/) | [C++](./C++/count-k-reducible-numbers-less-than-n.cpp) [Python](./Python/count-k-reducible-numbers-less-than-n.py) | _O(n^2)_ | _O(n)_ | Hard | | DP, Combinatorics
3359 | [Find Sorted Submatrices With Maximum Element at Most K](https://leetcode.com/problems/find-sorted-submatrices-with-maximum-element-at-most-k/) | [C++](./C++/find-sorted-submatrices-with-maximum-element-at-most-k.cpp) [Python](./Python/find-sorted-submatrices-with-maximum-element-at-most-k.py) | _O(m * n)_ | _O(m)_ | Hard |  🔒, variant of [Count Submatrices With All Ones](https://leetcode.com/problems/count-submatrices-with-all-ones/)  | Mono Stack, DP
3363 | [Find the Maximum Number of Fruits Collected](https://leetcode.com/problems/find-the-maximum-number-of-fruits-collected/) | [C++](./C++/find-the-maximum-number-of-fruits-collected.cpp) [Python](./Python/find-the-maximum-number-of-fruits-collected.py) | _O(n^2)_ | _O(1)_ | Hard | | DP
3366 | [Minimum Array Sum](https://leetcode.com/problems/minimum-array-sum/) | [C++](./C++/minimum-array-sum.cpp) [Python](./Python/minimum-array-sum.py) | _O(nlogn)_ | _O(n)_ | Medium | | DP, Greedy, Case Works
3372 | [Maximize the Number of Target Nodes After Connecting Trees I](https://leetcode.com/problems/maximize-the-number-of-target-nodes-after-connecting-trees-i/) | [C++](./C++/maximize-the-number-of-target-nodes-after-connecting-trees-i.cpp) [Python](./Python/maximize-the-number-of-target-nodes-after-connecting-trees-i.py) | _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](https://leetcode.com/problems/maximum-subarray-sum-with-length-divisible-by-k/) | [C++](./C++/maximum-subarray-sum-with-length-divisible-by-k.cpp) [Python](./Python/maximum-subarray-sum-with-length-divisible-by-k.py) | _O(n)_ | _O(k)_ | Medium | | Prefix Sum, DP
3388 | [Count Beautiful Splits in an Array](https://leetcode.com/problems/count-beautiful-splits-in-an-array/) | [C++](./C++/count-beautiful-splits-in-an-array.cpp) [Python](./Python/count-beautiful-splits-in-an-array.py) | _O(n^2)_ | _O(n)_ | Medium | | DP, `Z-Function`
3389 | [Minimum Operations to Make Character Frequencies Equal](https://leetcode.com/problems/minimum-operations-to-make-character-frequencies-equal/) | [C++](./C++/minimum-operations-to-make-character-frequencies-equal.cpp) [Python](./Python/minimum-operations-to-make-character-frequencies-equal.py) | _O(26 * n)_ | _O(26)_ | Hard | | Freq Table, DP
3393 | [Count Paths With the Given XOR Value](https://leetcode.com/problems/count-paths-with-the-given-xor-value/) | [C++](./C++/count-paths-with-the-given-xor-value.cpp) [Python](./Python/count-paths-with-the-given-xor-value.py) | _O(m * n * r)_ | _O(n * r)_ | Medium | | DP
3409 | [Longest Subsequence With Decreasing Adjacent Difference](https://leetcode.com/problems/longest-subsequence-with-decreasing-adjacent-difference/) | [C++](./C++/longest-subsequence-with-decreasing-adjacent-difference.cpp) [Python](./Python/longest-subsequence-with-decreasing-adjacent-difference.py) | _O(r^2 + n * r)_ | _O(r^2)_ | Medium | | DP
3414 | [Maximum Score of Non-overlapping Intervals](https://leetcode.com/problems/maximum-score-of-non-overlapping-intervals/) | [C++](./C++/maximum-score-of-non-overlapping-intervals.cpp) [Python](./Python/maximum-score-of-non-overlapping-intervals.py) | _O(nlogn + n * k^2)_ | _O(n * k^2)_ | Hard | | DP, Binary Search
3418 | [Maximum Amount of Money Robot Can Earn](https://leetcode.com/problems/maximum-amount-of-money-robot-can-earn/) | [C++](./C++/maximum-amount-of-money-robot-can-earn.cpp) [Python](./Python/maximum-amount-of-money-robot-can-earn.py) | _O(m * n)_ | _O(min(m, n))_ | Medium | | DP
3429 | [Paint House IV](https://leetcode.com/problems/paint-house-iv/) | [C++](./C++/paint-house-iv.cpp) [Python](./Python/paint-house-iv.py) | _O(n * l^4)_ | _O(l^2)_ | Medium | | DP
3434 | [Maximum Frequency After Subarray Operation](https://leetcode.com/problems/maximum-frequency-after-subarray-operation/) | [C++](./C++/maximum-frequency-after-subarray-operation.cpp) [Python](./Python/maximum-frequency-after-subarray-operation.py) | _O(n)_ | _O(n)_ | Medium | | Freq Table, DP
3441 | [Minimum Cost Good Caption](https://leetcode.com/problems/minimum-cost-good-caption/) | [C++](./C++/minimum-cost-good-caption.cpp) [Python](./Python/minimum-cost-good-caption.py) | _O(26 * n)_ | _O(26 * n)_ | Hard | | DP, Backtracing
3444 | [Minimum Increments for Target Multiples in an Array](https://leetcode.com/problems/minimum-increments-for-target-multiples-in-an-array/) | [C++](./C++/minimum-increments-for-target-multiples-in-an-array.cpp) [Python](./Python/minimum-increments-for-target-multiples-in-an-array.py) | _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](https://leetcode.com/problems/length-of-longest-v-shaped-diagonal-segment/) | [C++](./C++/length-of-longest-v-shaped-diagonal-segment.cpp) [Python](./Python/length-of-longest-v-shaped-diagonal-segment.py) | _O(n * m)_ | _O(n * m)_ | Hard | | Memoization, DP
3466 | [Maximum Coin Collection](https://leetcode.com/problems/maximum-coin-collection/) | [C++](./C++/maximum-coin-collection.cpp) [Python](./Python/maximum-coin-collection.py) | _O(n)_ | _O(1)_ | Medium | 🔒 | DP
3469 | [Find Minimum Cost to Remove Array Elements](https://leetcode.com/problems/find-minimum-cost-to-remove-array-elements/) | [C++](./C++/find-minimum-cost-to-remove-array-elements.cpp) [Python](./Python/find-minimum-cost-to-remove-array-elements.py) | _O(n^2)_ | _O(n)_ | Medium | | DP, Greedy
3472 | [Longest Palindromic Subsequence After at Most K Operations](https://leetcode.com/problems/longest-palindromic-subsequence-after-at-most-k-operations/) | [C++](./C++/longest-palindromic-subsequence-after-at-most-k-operations.cpp) [Python](./Python/longest-palindromic-subsequence-after-at-most-k-operations.py) | _O(n^2 * k)_ | _O(n^2 * k)_ | Medium | | DP
3473 | [Sum of K Subarrays With Length at Least M](https://leetcode.com/problems/sum-of-k-subarrays-with-length-at-least-m/) | [C++](./C++/sum-of-k-subarrays-with-length-at-least-m.cpp) [Python](./Python/sum-of-k-subarrays-with-length-at-least-m.py) | _O(k * n)_ | _O(n)_ | Medium | | Prefix Sum, DP
3489 | [Zero Array Transformation IV](https://leetcode.com/problems/zero-array-transformation-iv/) | [C++](./C++/zero-array-transformation-iv.cpp) [Python](./Python/zero-array-transformation-iv.py) | _O(n^2 * r * logq)_ | _O(r)_ | Medium | | Binary Search, DP
3490 | [Count Beautiful Numbers](https://leetcode.com/problems/count-beautiful-numbers/) | [C++](./C++/count-beautiful-numbers.cpp) [Python](./Python/count-beautiful-numbers.py) | _O(logr * 2 * 10 * s)_ | _O(logr * 2 * 10 * s)_ | Hard | | DP
3500 | [Minimum Cost to Divide Array Into Subarrays](https://leetcode.com/problems/minimum-cost-to-divide-array-into-subarrays/) | [C++](./C++/minimum-cost-to-divide-array-into-subarrays.cpp) [Python](./Python/minimum-cost-to-divide-array-into-subarrays.py) | _O(nlogn)_   | _O(n)_        | Hard         | | Prefix Sum, DP, Convex Hull Trick
3503 | [Longest Palindrome After Substring Concatenation I](https://leetcode.com/problems/longest-palindrome-after-substring-concatenation-i/) | [C++](./C++/longest-palindrome-after-substring-concatenation-i.cpp) [Python](./Python/longest-palindrome-after-substring-concatenation-i.py) | _O(n * m)_   | _O(n + m)_        | Medium         | | `Manacher's Algorithm`, DP
3504 | [Longest Palindrome After Substring Concatenation II](https://leetcode.com/problems/longest-palindrome-after-substring-concatenation-ii/) | [C++](./C++/longest-palindrome-after-substring-concatenation-ii.cpp) [Python](./Python/longest-palindrome-after-substring-concatenation-ii.py) | _O(n * m)_   | _O(n + m)_        | Hard         | | `Manacher's Algorithm`, DP
3505 | [Minimum Operations to Make Elements Within K Subarrays Equal](https://leetcode.com/problems/minimum-operations-to-make-elements-within-k-subarrays-equal/) | [C++](./C++/minimum-operations-to-make-elements-within-k-subarrays-equal.cpp) [Python](./Python/minimum-operations-to-make-elements-within-k-subarrays-equal.py) | _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](https://leetcode.com/problems/maximum-product-of-subsequences-with-an-alternating-sum-equal-to-k/) | [C++](./C++/maximum-product-of-subsequences-with-an-alternating-sum-equal-to-k.cpp) [Python](./Python/maximum-product-of-subsequences-with-an-alternating-sum-equal-to-k.py) | _O(n * k * l)_   | _O(n * k * l)_        | Hard         | | DP
3524 | [Find X Value of Array I](https://leetcode.com/problems/find-x-value-of-array-i/) | [C++](./C++/find-x-value-of-array-i.cpp) [Python](./Python/find-x-value-of-array-i.py) | _O(n * k)_   | _O(k)_        | Medium         | | DP
3525 | [Find X Value of Array II](https://leetcode.com/problems/find-x-value-of-array-ii/) | [C++](./C++/find-x-value-of-array-ii.cpp) [Python](./Python/find-x-value-of-array-ii.py) | _O(n * k + q * k * logn)_   | _O(n * k)_        | Hard         | | DP, Segment Tree
3530 | [Maximum Profit from Valid Topological Order in DAG](https://leetcode.com/problems/maximum-profit-from-valid-topological-order-in-dag/) | [C++](./C++/maximum-profit-from-valid-topological-order-in-dag.cpp) [Python](./Python/maximum-profit-from-valid-topological-order-in-dag.py) | _O(n * 2^n)_   | _O(2^n)_        | Hard         | | DP, Bitmasks
3533 | [Concatenated Divisibility](https://leetcode.com/problems/concatenated-divisibility/) | [C++](./C++/concatenated-divisibility.cpp) [Python](./Python/concatenated-divisibility.py) | _O(nlogr + k * n * 2^n)_   | _O(logr + k * 2^n)_        | Hard         | | DP, Bitmasks, Backtracing
3538 | [Merge Operations for Minimum Travel Time](https://leetcode.com/problems/merge-operations-for-minimum-travel-time/) | [C++](./C++/merge-operations-for-minimum-travel-time.cpp) [Python](./Python/merge-operations-for-minimum-travel-time.py) | _O((n-k) * k^3)_   | _O(k^2)_        | Hard         | | Prefix Sum, DP
3539 | [Find Sum of Array Product of Magical Sequences](https://leetcode.com/problems/find-sum-of-array-product-of-magical-sequences/) | [C++](./C++/find-sum-of-array-product-of-magical-sequences.cpp) [Python](./Python/find-sum-of-array-product-of-magical-sequences.py) | _O(n * k * m^2)_   | _O(k * m^2)_        | Hard         | | DP, Combinatorics
3543 | [Maximum Weighted K-Edge Path](https://leetcode.com/problems/maximum-weighted-k-edge-path/) | [C++](./C++/maximum-weighted-k-edge-path.cpp) [Python](./Python/maximum-weighted-k-edge-path.py) | _O(k * e * t)_   | _O(n * t)_        | Medium         | | DP
3544 | [Subtree Inversion Sum](https://leetcode.com/problems/subtree-inversion-sum/) | [C++](./C++/subtree-inversion-sum.cpp) [Python](./Python/subtree-inversion-sum.py) | _O(n)_   | _O(n)_        | Hard         | | DFS, Tree DP
3562 | [Maximum Profit from Trading Stocks with Discounts](https://leetcode.com/problems/maximum-profit-from-trading-stocks-with-discounts/) | [C++](./C++/maximum-profit-from-trading-stocks-with-discounts.cpp) [Python](./Python/maximum-profit-from-trading-stocks-with-discounts.py) | _O(n * b)_   | _O(n + b)_        | Hard         | | DFS, Tree DP
3563 | [Lexicographically Smallest String After Adjacent Removals](https://leetcode.com/problems/lexicographically-smallest-string-after-adjacent-removals/) | [C++](./C++/lexicographically-smallest-string-after-adjacent-removals.cpp) [Python](./Python/lexicographically-smallest-string-after-adjacent-removals.py) | _O(n^3)_   | _O(n^2)_        | Hard         | | DP
3573 | [Best Time to Buy and Sell Stock V](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-v/) | [C++](./C++/best-time-to-buy-and-sell-stock-v.cpp) [Python](./Python/best-time-to-buy-and-sell-stock-v.py) | _O(n * k)_   | _O(k)_        | Medium         | | DP
3574 | [Maximize Subarray GCD Score](https://leetcode.com/problems/maximize-subarray-gcd-score/) | [C++](./C++/maximize-subarray-gcd-score.cpp) [Python](./Python/maximize-subarray-gcd-score.py) | _O(nlogn * logr)_   | _O(n + logr)_        | Hard         | | Brute Force, Number Theory, Suffix-GCD States, DP, Binary Search
3575 | [Maximum Good Subtree Score](https://leetcode.com/problems/maximum-good-subtree-score/) | [C++](./C++/maximum-good-subtree-score.cpp) [Python](./Python/maximum-good-subtree-score.py) | _O(n * (2^10)^2)_   | _O(2^10)_        | Hard         | | Bitmasks, DFS, Tree DP
3578 | [Count Partitions With Max-Min Difference at Most K](https://leetcode.com/problems/count-partitions-with-max-min-difference-at-most-k/) | [C++](./C++/count-partitions-with-max-min-difference-at-most-k.cpp) [Python](./Python/count-partitions-with-max-min-difference-at-most-k.py) | _O(n)_   | _O(n)_        | Medium         | | Mono Deque, Two Pointers, Sliding Window, DP, Prefix Sum
3579 | [Minimum Steps to Convert String with Operations](https://leetcode.com/problems/minimum-steps-to-convert-string-with-operations/) | [C++](./C++/minimum-steps-to-convert-string-with-operations.cpp) [Python](./Python/minimum-steps-to-convert-string-with-operations.py) | _O(n^2)_   | _O(26^2)_        | Hard         | | DP
3583 | [Count Special Triplets](https://leetcode.com/problems/count-special-triplets/) | [C++](./C++/count-special-triplets.cpp) [Python](./Python/count-special-triplets.py) | _O(n)_   | _O(n)_        | Medium         | | DP, Freq Table
3592 | [Inverse Coin Change](https://leetcode.com/problems/inverse-coin-change/) | [C++](./C++/inverse-coin-change.cpp) [Python](./Python/inverse-coin-change.py) | _O(n^2)_   | _O(1)_        | Medium         | | DP
3595 | [Once Twice](https://leetcode.com/problems/once-twice/) | [C++](./C++/once-twice.cpp) [Python](./Python/once-twice.py) | _O(n)_   | _O(1)_        | Medium         | 🔒 | DP, Bitmasks
3599 | [Partition Array to Minimize XOR](https://leetcode.com/problems/partition-array-to-minimize-xor/) | [C++](./C++/partition-array-to-minimize-xor.cpp) [Python](./Python/partition-array-to-minimize-xor.py) | _O(n^2 * k)_   | _O(n)_        | Medium         | | DP, Prefix Sum
3603 | [Minimum Cost Path with Alternating Directions II](https://leetcode.com/problems/minimum-cost-path-with-alternating-directions-ii/) | [C++](./C++/minimum-cost-path-with-alternating-directions-ii.cpp) [Python](./Python/minimum-cost-path-with-alternating-directions-ii.py) | _O(m * n)_   | _O(1)_        | Medium         | | DP
3610 | [Minimum Number of Primes to Sum to Target](https://leetcode.com/problems/minimum-number-of-primes-to-sum-to-target/) | [C++](./C++/minimum-number-of-primes-to-sum-to-target.cpp) [Python](./Python/minimum-number-of-primes-to-sum-to-target.py) | _O(nlog(log(min(m, n))) + m * n)_   | _O(n)_        | Medium         | 🔒 | Number Theory, Knapsack DP
3615 | [Longest Palindromic Path in Graph](https://leetcode.com/problems/longest-palindromic-path-in-graph/) | [C++](./C++/longest-palindromic-path-in-graph.cpp) [Python](./Python/longest-palindromic-path-in-graph.py) | _O(n^4 * 2^n)_   | _O(n + e)_        | Hard         | | Bitmasks, DP, Freq Table
3628 | [Maximum Number of Subsequences After One Inserting](https://leetcode.com/problems/maximum-number-of-subsequences-after-one-inserting/) | [C++](./C++/maximum-number-of-subsequences-after-one-inserting.cpp) [Python](./Python/maximum-number-of-subsequences-after-one-inserting.py) | _O(n)_   | _O(1)_        | Medium         | | Prefix Sum, DP
3647 | [Maximum Weight in Two Bags](https://leetcode.com/problems/maximum-weight-in-two-bags/) | [C++](./C++/maximum-weight-in-two-bags.cpp) [Python](./Python/maximum-weight-in-two-bags.py) | _O(n * w1 * w2)_   | _O(w1 * w2)_        | Medium         | 🔒 | DP, Bitset
3651 | [Minimum Cost Path with Teleportations](https://leetcode.com/problems/minimum-cost-path-with-teleportations/) | [C++](./C++/minimum-cost-path-with-teleportations.cpp) [Python](./Python/minimum-cost-path-with-teleportations.py) | _O(k * (m * n + r))_   | _O(m * n + r)_        | Hard         | | DP, Prefix Sum
3654 | [Minimum Sum After Divisible Sum Deletions](https://leetcode.com/problems/minimum-sum-after-divisible-sum-deletions/) | [C++](./C++/minimum-sum-after-divisible-sum-deletions.cpp) [Python](./Python/minimum-sum-after-divisible-sum-deletions.py) | _O(n + k)_   | _O(k)_        | Medium         | | DP, Prefix Sum
3661 | [Maximum Walls Destroyed by Robots](https://leetcode.com/problems/maximum-walls-destroyed-by-robots/) | [C++](./C++/maximum-walls-destroyed-by-robots.cpp) [Python](./Python/maximum-walls-destroyed-by-robots.py) | _O(nlogn + mlogm)_   | _O(n)_        | Hard         | | Sort, DP, Two Pointers
3665 | [Twisted Mirror Path Count](https://leetcode.com/problems/twisted-mirror-path-count/) | [C++](./C++/twisted-mirror-path-count.cpp) [Python](./Python/twisted-mirror-path-count.py) | _O(m * n)_   | _O(min(m, n))_        | Medium         | | DP
3670 | [Maximum Product of Two Integers With No Common Bits](https://leetcode.com/problems/maximum-product-of-two-integers-with-no-common-bits/) | [C++](./C++/maximum-product-of-two-integers-with-no-common-bits.cpp) [Python](./Python/maximum-product-of-two-integers-with-no-common-bits.py) | _O(n + rlogr)_   | _O(r)_        | Medium         | | DP, Bitmasks
3685 | [Subsequence Sum After Capping Elements](https://leetcode.com/problems/subsequence-sum-after-capping-elements/) | [C++](./C++/subsequence-sum-after-capping-elements.cpp) [Python](./Python/subsequence-sum-after-capping-elements.py) | _O(nlogn + n * k)_   | _O(k)_        | Medium         | | Sort, DP, Bitmasks
3686 | [Number of Stable Subsequences](https://leetcode.com/problems/number-of-stable-subsequences/) | [C++](./C++/number-of-stable-subsequences.cpp) [Python](./Python/number-of-stable-subsequences.py) | _O(n)_   | _O(1)_        | Hard         | | DP
3693 | [Climbing Stairs II](https://leetcode.com/problems/climbing-stairs-ii/) | [C++](./C++/climbing-stairs-ii.cpp) [Python](./Python/climbing-stairs-ii.py) | _O(n)_   | _O(1)_        | Medium         | | DP
3699 | [Number of ZigZag Arrays I](https://leetcode.com/problems/number-of-zigzag-arrays-i/) | [C++](./C++/number-of-zigzag-arrays-i.cpp) [Python](./Python/number-of-zigzag-arrays-i.py) | _O(n * (r - l))_   | _O(r - l)_        | Hard         | | DP
3704 | [Count No-Zero Pairs That Sum to N](https://leetcode.com/problems/count-no-zero-pairs-that-sum-to-n/) | [C++](./C++/count-no-zero-pairs-that-sum-to-n.cpp) [Python](./Python/count-no-zero-pairs-that-sum-to-n.py) | _O(10 * 2^4 * logn)_   | _O(2^3)_        | Hard         | | DP
3717 | [Minimum Operations to Make the Array Beautiful](https://leetcode.com/problems/minimum-operations-to-make-the-array-beautiful/) | [C++](./C++/minimum-operations-to-make-the-array-beautiful.cpp) [Python](./Python/minimum-operations-to-make-the-array-beautiful.py) | _O(n * rlogr)_   | _O(r)_        | Medium         | 🔒 | DP
3725 | [Count Ways to Choose Coprime Integers from Rows](https://leetcode.com/problems/count-ways-to-choose-coprime-integers-from-rows/) | [C++](./C++/count-ways-to-choose-coprime-integers-from-rows.cpp) [Python](./Python/count-ways-to-choose-coprime-integers-from-rows.py) | _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](https://leetcode.com/problems/maximum-path-score-in-a-grid/) | [C++](./C++/maximum-path-score-in-a-grid.cpp) [Python](./Python/maximum-path-score-in-a-grid.py) | _O(m * n * k)_   | _O(m * n * k)_        | Medium         | | DP
3743 | [Maximize Cyclic Partition Score](https://leetcode.com/problems/maximize-cyclic-partition-score/) | [C++](./C++/maximize-cyclic-partition-score.cpp) [Python](./Python/maximize-cyclic-partition-score.py) | _O(n * k)_   | _O(k)_        | Hard         | variant of [Best Time to Buy and Sell Stock V](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-v/) | DP
3753 | [Total Waviness of Numbers in Range II](https://leetcode.com/problems/total-waviness-of-numbers-in-range-ii/) | [C++](./C++/total-waviness-of-numbers-in-range-ii.cpp) [Python](./Python/total-waviness-of-numbers-in-range-ii.py) | _O(logn * 11 * 11 * 2 * 2 * 10)_ | _O(11 * 11 * 2 * 2)_ | Hard | | DP, Memoization
3757 | [Number of Effective Subsequences](https://leetcode.com/problems/number-of-effective-subsequences/) | [C++](./C++/number-of-effective-subsequences.cpp) [Python](./Python/number-of-effective-subsequences.py) | _O((n + r) * logr)_ | _O(n + r)_ | Hard | | SOS DP, Principle of Inclusion and Exclusion
3772 | [Maximum Subgraph Score in a Tree](https://leetcode.com/problems/maximum-subgraph-score-in-a-tree/)| [C++](./C++/maximum-subgraph-score-in-a-tree.cpp) [Python](./Python/maximum-subgraph-score-in-a-tree.py)| _O(n)_ | _O(n)_ | Hard | | BFS, Tree DP |
3791 | [Number of Balanced Integers in a Range](https://leetcode.com/problems/number-of-balanced-integers-in-a-range/) | [C++](./C++/number-of-balanced-integers-in-a-range.cpp) [Python](./Python/number-of-balanced-integers-in-a-range.py) | _O((logn)^2)_ | _O(logn)_ | Hard | | DP, Memoization
3801 | [Minimum Cost to Merge Sorted Lists](https://leetcode.com/problems/minimum-cost-to-merge-sorted-lists/) | [C++](./C++/minimum-cost-to-merge-sorted-lists.cpp) [Python](./Python/minimum-cost-to-merge-sorted-lists.py) | _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](https://leetcode.com/problems/number-of-alternating-xor-partitions/)| [C++](./C++/number-of-alternating-xor-partitions.cpp) [Python](./Python/number-of-alternating-xor-partitions.py)| _O(n)_ | _O(1)_ | Medium | | DP, Freq Table |
3830 | [Longest Alternating Subarray After Removing At Most One Element](https://leetcode.com/problems/longest-alternating-subarray-after-removing-at-most-one-element/)| [C++](./C++/longest-alternating-subarray-after-removing-at-most-one-element.cpp) [Python](./Python/longest-alternating-subarray-after-removing-at-most-one-element.py)| _O(n)_ | _O(1)_ | Hard | | DP, Prefix Sum |
3836 | [Maximum Score Using Exactly K Pairs](https://leetcode.com/problems/maximum-score-using-exactly-k-pairs/)| [C++](./C++/maximum-score-using-exactly-k-pairs.cpp) [Python](./Python/maximum-score-using-exactly-k-pairs.py)| _O(n * m * k)_ | _O(min(n, m) * k)_ | Hard | | DP |
3840 | [House Robber V](https://leetcode.com/problems/house-robber-v/)| [C++](./C++/house-robber-v.cpp) [Python](./Python/house-robber-v.py)| _O(n)_ | _O(1)_ | Medium | | DP |
3850 | [Count Sequences to K](https://leetcode.com/problems/count-sequences-to-k/)| [C++](./C++/count-sequences-to-k.cpp) [Python](./Python/count-sequences-to-k.py)| _O(3^(n/2))_ | _O(3^(n/2))_ | Hard | | DP, Meet in The Middle |
3864 | [Minimum Cost to Partition a Binary String](https://leetcode.com/problems/minimum-cost-to-partition-a-binary-string/) | [C++](./C++/minimum-cost-to-partition-a-binary-string.cpp) [Python](./Python/minimum-cost-to-partition-a-binary-string.py) | _O(n)_ | _O(n)_ | Hard | | Prefix Sum, Divide and Conquer, DP
3869 | [Count Fancy Numbers in a Range](https://leetcode.com/problems/count-fancy-numbers-in-a-range/) | [C++](./C++/count-fancy-numbers-in-a-range.cpp) [Python](./Python/count-fancy-numbers-in-a-range.py) | _O(g * d + d^2)_ | _O(g + d)_ | Hard | | BFS, DP, Principle of Inclusion and Exclusion
3877 | [Minimum Removals to Achieve Target XOR](https://leetcode.com/problems/minimum-removals-to-achieve-target-xor/) | [C++](./C++/minimum-removals-to-achieve-target-xor.cpp) [Python](./Python/minimum-removals-to-achieve-target-xor.py) | _O(n * r)_ | _O(r)_ | Medium | | Bitmasks, DP, BFS
3882 | [Minimum XOR Path in a Grid](https://leetcode.com/problems/minimum-xor-path-in-a-grid/) | [C++](./C++/minimum-xor-path-in-a-grid.cpp) [Python](./Python/minimum-xor-path-in-a-grid.py) | _O(m * n * r)_ | _O(n * r)_ | Medium | | DP
3883 | [Count Non Decreasing Arrays With Given Digit Sums](https://leetcode.com/problems/count-non-decreasing-arrays-with-given-digit-sums/) | [C++](./C++/count-non-decreasing-arrays-with-given-digit-sums.cpp) [Python](./Python/count-non-decreasing-arrays-with-given-digit-sums.py) | precompute: _O(rlogr)_runtime: _O(n * r)_ | _O(r)_ | Medium | | DP, Prefix Sum
3891 | [Minimum Increase to Maximize Special Indices](https://leetcode.com/problems/minimum-increase-to-maximize-special-indices/) | [C++](./C++/minimum-increase-to-maximize-special-indices.cpp) [Python](./Python/minimum-increase-to-maximize-special-indices.py) | _O(n)_ | _O(1)_ | Medium | | DP
3906 | [Count Good Integers on a Grid Path](https://leetcode.com/problems/count-good-integers-on-a-grid-path/) | [C++](./C++/count-good-integers-on-a-grid-path.cpp) [Python](./Python/count-good-integers-on-a-grid-path.py) | _O(16 * 2 * 10 * 10)_ | _O(16 + 2 * 10)_ | Hard | | Memoization, DP
3916 | [Number of ZigZag Arrays III](https://leetcode.com/problems/number-of-zigzag-arrays-iii/) | [C++](./C++/number-of-zigzag-arrays-iii.cpp) [Python](./Python/number-of-zigzag-arrays-iii.py) | _O(n^3)_ | _O(n)_ | Hard | 🔒 | DP, Prefix Sum, Combinatorics, `Lagrange Interpolation`
3939 | [Count Non Adjacent Subsets in a Rooted Tree](https://leetcode.com/problems/count-non-adjacent-subsets-in-a-rooted-tree/) | [C++](./C++/count-non-adjacent-subsets-in-a-rooted-tree.cpp) [Python](./Python/count-non-adjacent-subsets-in-a-rooted-tree.py) | _O(n * k^2)_ | _O(n * k)_ | Hard | 🔒 | Topological Sort, Tree DP
3946 | [Maximum Number of Items From Sale I](https://leetcode.com/problems/maximum-number-of-items-from-sale-i/) | [C++](./C++/maximum-number-of-items-from-sale-i.cpp) [Python](./Python/maximum-number-of-items-from-sale-i.py) | _O(rlogr + n * b)_ | _O(r + b)_ | Medium | | Freq Table, Knapsack DP
3949 | [Subtree Inversion Sum II](https://leetcode.com/problems/subtree-inversion-sum-ii/) | [C++](./C++/subtree-inversion-sum-ii.cpp) [Python](./Python/subtree-inversion-sum-ii.py) | _O(n * k)_ | _O(n + h * k)_ | Hard | 🔒 | DFS, Tree DP
3953 | [Maximum Score with Co-Prime Element](https://leetcode.com/problems/maximum-score-with-co-prime-element/) | [C++](./C++/maximum-score-with-co-prime-element.cpp) [Python](./Python/maximum-score-with-co-prime-element.py) | _O(n + rlogr)_   | _O(r)_        | Hard         | | DP, Number Theory, `Linear Sieve of Eratosthenes`, Mobius Function, Principle of Inclusion-Exclusion
3965 | [Finish Time of Tasks I](https://leetcode.com/problems/finish-time-of-tasks-i/) | [C++](./C++/finish-time-of-tasks-i.cpp) [Python](./Python/finish-time-of-tasks-i.py) | _O(n)_   | _O(n)_        | Medium         | | DFS, Tree DP
3966 | [Count Good Integers in a Range](https://leetcode.com/problems/count-good-integers-in-a-range/) | [C++](./C++/count-good-integers-in-a-range.cpp) [Python](./Python/count-good-integers-in-a-range.py) | _O(10 * logr)_   | _O(10)_        | Hard         | | DP, Prefix Sum
3967 | [Finish Time of Tasks II](https://leetcode.com/problems/finish-time-of-tasks-ii/) | [C++](./C++/finish-time-of-tasks-ii.cpp) [Python](./Python/finish-time-of-tasks-ii.py) | _O(n)_   | _O(n)_        | Hard         | 🔒  | DFS, Tree DP
3976 | [Maximum Subarray Sum After Multiplier](https://leetcode.com/problems/maximum-subarray-sum-after-multiplier/) | [C++](./C++/maximum-subarray-sum-after-multiplier.cpp) [Python](./Python/maximum-subarray-sum-after-multiplier.py) | _O(n)_   | _O(1)_        | Medium         |  | DP, `Kadane's Algorithm`
3981 | [Count Distinct Ways to Form Target from Two Strings](https://leetcode.com/problems/count-distinct-ways-to-form-target-from-two-strings/) | [C++](./C++/count-distinct-ways-to-form-target-from-two-strings.cpp) [Python](./Python/count-distinct-ways-to-form-target-from-two-strings.py) | _O(n * m * t)_   | _O(n * m)_        | Hard         |  | DP, Prefix Sum
3983 | [Subsequence After One Replacement](https://leetcode.com/problems/subsequence-after-one-replacement/) | [C++](./C++/subsequence-after-one-replacement.cpp) [Python](./Python/subsequence-after-one-replacement.py) | _O(n + m)_   | _O(1)_        | Medium         |  | DP
3989 | [Maximum Consistent Columns in a Grid](https://leetcode.com/problems/maximum-consistent-columns-in-a-grid/) | [C++](./C++/maximum-consistent-columns-in-a-grid.cpp) [Python](./Python/maximum-consistent-columns-in-a-grid.py) | _O(m * n^2 / 64)_   | _O(n^2 / 64)_        | Hard         |  | Sort, Prefix Sum, Binary Search, DP, Bitmasks
3995 | [Minimum Cost to Convert String III](https://leetcode.com/problems/minimum-cost-to-convert-string-iii/) | [C++](./C++/minimum-cost-to-convert-string-iii.cpp) [Python](./Python/minimum-cost-to-convert-string-iii.py) | _O(n * r * l)_   | _O(min(n, l))_        | Hard         |  | DP
4009 | [Minimum Possible Maximum Waiting Time](https://leetcode.com/problems/minimum-possible-maximum-waiting-time/) | [C++](./C++/minimum-possible-maximum-waiting-time.cpp) [Python](./Python/minimum-possible-maximum-waiting-time.py) | _O(n * rlogr)_   | _O(r)_        | Hard         |  | Binary Search, DP, Bitmasks
4016 | [Maximum Area of Two Non-Overlapping Square Submatrices](https://leetcode.com/problems/maximum-area-of-two-non-overlapping-square-submatrices/) | [C++](./C++/maximum-area-of-two-non-overlapping-square-submatrices.cpp) [Python](./Python/maximum-area-of-two-non-overlapping-square-submatrices.py) | _O(m * n)_   | _O(n + min(m, n))_        | Medium         |  | DP



    **[⬆️ Back to Top](#algorithms)**



## Greedy
|  #  | Title           |  Solution       |  Time           | Space           | Difficulty    | Tag          | Note| 
|-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------|-----|
3002 | [Maximum Size of a Set After Removals](https://leetcode.com/problems/maximum-size-of-a-set-after-removals/) | [C++](./C++/maximum-size-of-a-set-after-removals.cpp) [Python](./Python/maximum-size-of-a-set-after-removals.py) | _O(n)_ | _O(n)_ | Medium | | Math, Hash Table, Greedy
3003 | [Maximize the Number of Partitions After Operations](https://leetcode.com/problems/maximize-the-number-of-partitions-after-operations/) | [C++](./C++/maximize-the-number-of-partitions-after-operations.cpp) [Python](./Python/maximize-the-number-of-partitions-after-operations.py) | _O(n)_ | _O(n)_ | Hard | | Prefix Sum, Greedy
3012 | [Minimize Length of Array Using Operations](https://leetcode.com/problems/minimize-length-of-array-using-operations/) | [C++](./C++/minimize-length-of-array-using-operations.cpp) [Python](./Python/minimize-length-of-array-using-operations.py) | _O(n)_ | _O(1)_ | Medium | | Greedy
3014 | [Minimum Number of Pushes to Type Word I](https://leetcode.com/problems/minimum-number-of-pushes-to-type-word-i/) | [C++](./C++/minimum-number-of-pushes-to-type-word-i.cpp) [Python](./Python/minimum-number-of-pushes-to-type-word-i.py) | _O(4)_ | _O(1)_ | Easy | | Freq Table, Greedy
3016 | [Minimum Number of Pushes to Type Word II](https://leetcode.com/problems/minimum-number-of-pushes-to-type-word-ii/) | [C++](./C++/minimum-number-of-pushes-to-type-word-ii.cpp) [Python](./Python/minimum-number-of-pushes-to-type-word-ii.py) | _O(n)_ | _O(26)_ | Medium | | Freq Table, Greedy
3022 | [Minimize OR of Remaining Elements Using Operations](https://leetcode.com/problems/minimize-or-of-remaining-elements-using-operations/) | [C++](./C++/minimize-or-of-remaining-elements-using-operations.cpp) [Python](./Python/minimize-or-of-remaining-elements-using-operations.py) | _O(nlogr)_ | _O(1)_ | Hard | | Bitmasks, Greedy
3035 | [Maximum Palindromes After Operations](https://leetcode.com/problems/maximum-palindromes-after-operations/) | [C++](./C++/maximum-palindromes-after-operations.cpp) [Python](./Python/maximum-palindromes-after-operations.py) | _O(n * l + nlogn)_ | _O(n)_ | Medium | | Freq Table, Greedy, Sort
3068 | [Find the Maximum Sum of Node Values](https://leetcode.com/problems/find-the-maximum-sum-of-node-values/) | [C++](./C++/find-the-maximum-sum-of-node-values.cpp) [Python](./Python/find-the-maximum-sum-of-node-values.py) | _O(n)_ | _O(1)_ | Hard | | Greedy
3074 | [Apple Redistribution into Boxes](https://leetcode.com/problems/apple-redistribution-into-boxes/) | [C++](./C++/apple-redistribution-into-boxes.cpp) [Python](./Python/apple-redistribution-into-boxes.py) | _O(nlogn)_ | _O(1)_ | Easy | | Sort, Greedy
3075 | [Maximize Happiness of Selected Children](https://leetcode.com/problems/maximize-happiness-of-selected-children/) | [C++](./C++/maximize-happiness-of-selected-children.cpp) [Python](./Python/maximize-happiness-of-selected-children.py) | _O(nlogn)_ | _O(1)_ | Medium | | Sort, Greedy
3086 | [Minimum Moves to Pick K Ones](https://leetcode.com/problems/minimum-moves-to-pick-k-ones/) | [C++](./C++/minimum-moves-to-pick-k-ones.cpp) [Python](./Python/minimum-moves-to-pick-k-ones.py) | _O(n)_ | _O(n)_ | Hard | | Prefix Sum, Greedy
3088 | [Make String Anti-palindrome](https://leetcode.com/problems/make-string-anti-palindrome/) | [C++](./C++/make-string-anti-palindrome.cpp) [Python](./Python/make-string-anti-palindrome.py) | _O(n + 26)_ | _O(26)_ | Hard | 🔒 | Freq Table, Counting Sort, Greedy, Two Pointers
3106 | [Lexicographically Smallest String After Operations With Constraint](https://leetcode.com/problems/lexicographically-smallest-string-after-operations-with-constraint/) | [C++](./C++/lexicographically-smallest-string-after-operations-with-constraint.cpp) [Python](./Python/lexicographically-smallest-string-after-operations-with-constraint.py) | _O(n)_ | _O(1)_ | Medium | | Greedy
3107 | [Minimum Operations to Make Median of Array Equal to K](https://leetcode.com/problems/minimum-operations-to-make-median-of-array-equal-to-k/) | [C++](./C++/minimum-operations-to-make-median-of-array-equal-to-k.cpp) [Python](./Python/minimum-operations-to-make-median-of-array-equal-to-k.py) | _O(n)_ | _O(1)_ | Medium | | Sort, Quick Select, Greedy
3111 | [Minimum Rectangles to Cover Points](https://leetcode.com/problems/minimum-rectangles-to-cover-points/) | [C++](./C++/minimum-rectangles-to-cover-points.cpp) [Python](./Python/minimum-rectangles-to-cover-points.py) | _O(nlogn)_ | _O(n)_ | Medium | | Sort, Greedy
3114 | [Latest Time You Can Obtain After Replacing Characters](https://leetcode.com/problems/latest-time-you-can-obtain-after-replacing-characters/)| [C++](./C++/latest-time-you-can-obtain-after-replacing-characters.cpp) [Python](./Python/latest-time-you-can-obtain-after-replacing-characters.py)| _O(1)_ | _O(1)_ | Easy | | String, Greedy |
3119 | [Maximum Number of Potholes That Can Be Fixed](https://leetcode.com/problems/maximum-number-of-potholes-that-can-be-fixed/)| [C++](./C++/maximum-number-of-potholes-that-can-be-fixed.cpp) [Python](./Python/maximum-number-of-potholes-that-can-be-fixed.py)| _O(n)_ | _O(n)_ | Medium | 🔒 | Sort, Counting Sort, Greedy |
3170 | [Lexicographically Minimum String After Removing Stars](https://leetcode.com/problems/lexicographically-minimum-string-after-removing-stars/)| [C++](./C++/lexicographically-minimum-string-after-removing-stars.cpp) [Python](./Python/lexicographically-minimum-string-after-removing-stars.py)| _O(n + 26)_ | _O(n + 26)_ | Medium | | Greedy, Hash Table, Stack |
3189 | [Minimum Moves to Get a Peaceful Board](https://leetcode.com/problems/minimum-moves-to-get-a-peaceful-board/) | [C++](./C++/minimum-moves-to-get-a-peaceful-board.cpp) [Python](./Python/minimum-moves-to-get-a-peaceful-board.py) | _O(n)_ | _O(n)_ | Medium | 🔒, variant of [Distribute Coins in Binary Tree](https://leetcode.com/problems/distribute-coins-in-binary-tree/) | Counting Sort, Prefix Sum, Greedy
3191 | [Minimum Operations to Make Binary Array Elements Equal to One I](https://leetcode.com/problems/minimum-operations-to-make-binary-array-elements-equal-to-one-i/) | [C++](./C++/minimum-operations-to-make-binary-array-elements-equal-to-one-i.cpp) [Python](./Python/minimum-operations-to-make-binary-array-elements-equal-to-one-i.py) | _O(n)_ | _O(1)_ | Medium | | Greedy
3192 | [Minimum Operations to Make Binary Array Elements Equal to One II](https://leetcode.com/problems/minimum-operations-to-make-binary-array-elements-equal-to-one-ii/) | [C++](./C++/minimum-operations-to-make-binary-array-elements-equal-to-one-ii.cpp) [Python](./Python/minimum-operations-to-make-binary-array-elements-equal-to-one-ii.py) | _O(n)_ | _O(1)_ | Medium | | Greedy
3205 | [Maximum Array Hopping Score I](https://leetcode.com/problems/maximum-array-hopping-score-i/)| [C++](./C++/maximum-array-hopping-score-i.cpp) [Python](./Python/maximum-array-hopping-score-i.py)| _O(n)_ | _O(1)_ | Medium | 🔒 | DP, Prefix Sum, Greedy |
3207 | [Maximum Points After Enemy Battles](https://leetcode.com/problems/maximum-points-after-enemy-battles/)| [C++](./C++/maximum-points-after-enemy-battles.cpp) [Python](./Python/maximum-points-after-enemy-battles.py)| _O(n)_ | _O(1)_ | Medium | | Greedy |
3216 | [Lexicographically Smallest String After a Swap](https://leetcode.com/problems/lexicographically-smallest-string-after-a-swap/)| [C++](./C++/lexicographically-smallest-string-after-a-swap.cpp) [Python](./Python/lexicographically-smallest-string-after-a-swap.py)| _O(n)_ | _O(1)_ | Easy | | Greedy |
3218 | [Minimum Cost for Cutting Cake I](https://leetcode.com/problems/minimum-cost-for-cutting-cake-i/)| [C++](./C++/minimum-cost-for-cutting-cake-i.cpp) [Python](./Python/minimum-cost-for-cutting-cake-i.py)| _O(mlogm + nlogn)_ | _O(1)_ | Medium | | Memoization, Greedy |
3219 | [Minimum Cost for Cutting Cake II](https://leetcode.com/problems/minimum-cost-for-cutting-cake-ii/)| [C++](./C++/minimum-cost-for-cutting-cake-ii.cpp) [Python](./Python/minimum-cost-for-cutting-cake-ii.py)| _O(mlogm + nlogn)_ | _O(1)_ | Hard | | Greedy |
3221 | [Maximum Array Hopping Score II](https://leetcode.com/problems/maximum-array-hopping-score-ii/)| [C++](./C++/maximum-array-hopping-score-ii.cpp) [Python](./Python/maximum-array-hopping-score-ii.py)| _O(n)_ | _O(1)_ | Medium | 🔒 | Prefix Sum, Greedy |
3228 | [Maximum Number of Operations to Move Ones to the End](https://leetcode.com/problems/maximum-number-of-operations-to-move-ones-to-the-end/)| [C++](./C++/maximum-number-of-operations-to-move-ones-to-the-end.cpp) [Python](./Python/maximum-number-of-operations-to-move-ones-to-the-end.py)| _O(n)_ | _O(1)_ | Medium | | Greedy |
3229 | [Minimum Operations to Make Array Equal to Target](https://leetcode.com/problems/minimum-operations-to-make-array-equal-to-target/)| [C++](./C++/minimum-operations-to-make-array-equal-to-target.cpp) [Python](./Python/minimum-operations-to-make-array-equal-to-target.py)| _O(n)_ | _O(1)_ | Hard | variant of [Minimum Number of Increments on Subarrays to Form a Target Array](https://leetcode.com/problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array/) | Greedy |
3239 | [Minimum Number of Flips to Make Binary Grid Palindromic I](https://leetcode.com/problems/minimum-number-of-flips-to-make-binary-grid-palindromic-i/) | [C++](./C++/minimum-number-of-flips-to-make-binary-grid-palindromic-i.cpp) [Python](./Python/minimum-number-of-flips-to-make-binary-grid-palindromic-i.py) | _O(m * n)_   | _O(1)_        | Medium         | | Array, Greedy
3240 | [Minimum Number of Flips to Make Binary Grid Palindromic II](https://leetcode.com/problems/minimum-number-of-flips-to-make-binary-grid-palindromic-ii/) | [C++](./C++/minimum-number-of-flips-to-make-binary-grid-palindromic-ii.cpp) [Python](./Python/minimum-number-of-flips-to-make-binary-grid-palindromic-ii.py) | _O(m * n)_   | _O(1)_        | Medium         | | Array, Greedy
3273 | [Minimum Amount of Damage Dealt to Bob](https://leetcode.com/problems/minimum-amount-of-damage-dealt-to-bob/) | [C++](./C++/minimum-amount-of-damage-dealt-to-bob.cpp) [Python](./Python/minimum-amount-of-damage-dealt-to-bob.py) | _O(nlogn)_   | _O(n)_        | Hard         | | Sort, Greedy
3282 | [Reach End of Array With Max Score](https://leetcode.com/problems/reach-end-of-array-with-max-score/) | [C++](./C++/reach-end-of-array-with-max-score.cpp) [Python](./Python/reach-end-of-array-with-max-score.py) | _O(n)_   | _O(1)_        | Medium         | | Greedy
3301 | [Maximize the Total Height of Unique Towers](https://leetcode.com/problems/maximize-the-total-height-of-unique-towers/) | [C++](./C++/maximize-the-total-height-of-unique-towers.cpp) [Python](./Python/maximize-the-total-height-of-unique-towers.py) | _O(nlogn)_   | _O(1)_        | Medium         | | Sort, Greedy
3302 | [Find the Lexicographically Smallest Valid Sequence](https://leetcode.com/problems/find-the-lexicographically-smallest-valid-sequence/) | [C++](./C++/find-the-lexicographically-smallest-valid-sequence.cpp) [Python](./Python/find-the-lexicographically-smallest-valid-sequence.py) | _O(n + m)_   | _O(m)_        | Medium         | | Hash Table, Greedy
3362 | [Zero Array Transformation III](https://leetcode.com/problems/zero-array-transformation-iii/) | [C++](./C++/zero-array-transformation-iii.cpp) [Python](./Python/zero-array-transformation-iii.py) | _O(n + qlogq)_   | _O(q)_        | Medium         | | Sort, Heap, Greedy
3397 | [Maximum Number of Distinct Elements After Operations](https://leetcode.com/problems/maximum-number-of-distinct-elements-after-operations/) | [C++](./C++/maximum-number-of-distinct-elements-after-operations.cpp) [Python](./Python/maximum-number-of-distinct-elements-after-operations.py) | _O(nlogn)_   | _O(1)_        | Medium         | | Sort, Greedy
3402 | [Minimum Operations to Make Columns Strictly Increasing](https://leetcode.com/problems/minimum-operations-to-make-columns-strictly-increasing/) | [C++](./C++/minimum-operations-to-make-columns-strictly-increasing.cpp) [Python](./Python/minimum-operations-to-make-columns-strictly-increasing.py) | _O(m * n)_   | _O(1)_        | Easy         | | Greedy
3403 | [Find the Lexicographically Largest String From the Box I](https://leetcode.com/problems/find-the-lexicographically-largest-string-from-the-box-i/) | [C++](./C++/find-the-lexicographically-largest-string-from-the-box-i.cpp) [Python](./Python/find-the-lexicographically-largest-string-from-the-box-i.py) | _O(n)_   | _O(1)_        | Medium         | | Greedy
3406 | [Find the Lexicographically Largest String From the Box II](https://leetcode.com/problems/find-the-lexicographically-largest-string-from-the-box-ii/) | [C++](./C++/find-the-lexicographically-largest-string-from-the-box-ii.cpp) [Python](./Python/find-the-lexicographically-largest-string-from-the-box-ii.py) | _O(n)_   | _O(1)_        | Hard         | 🔒 | Greedy
3410 | [Maximize Subarray Sum After Removing All Occurrences of One Element](https://leetcode.com/problems/maximize-subarray-sum-after-removing-all-occurrences-of-one-element/) | [C++](./C++/maximize-subarray-sum-after-removing-all-occurrences-of-one-element.cpp) [Python](./Python/maximize-subarray-sum-after-removing-all-occurrences-of-one-element.py) | _O(n)_   | _O(n)_        | Hard         | | Prefix Sum, Greedy, `Kadane's Algorithm`, Segment Tree
3424 | [Minimum Cost to Make Arrays Identical](https://leetcode.com/problems/minimum-cost-to-make-arrays-identical/) | [C++](./C++/minimum-cost-to-make-arrays-identical.cpp) [Python](./Python/minimum-cost-to-make-arrays-identical.py) | _O(nlogn)_   | _O(1)_        | Medium         | | Sort, Greedy
3443 | [Maximum Manhattan Distance After K Changes](https://leetcode.com/problems/maximum-manhattan-distance-after-k-changes/) | [C++](./C++/maximum-manhattan-distance-after-k-changes.cpp) [Python](./Python/maximum-manhattan-distance-after-k-changes.py) | _O(n)_   | _O(1)_        | Medium         | | Greedy
3457 | [Eat Pizzas!](https://leetcode.com/problems/eat-pizzas/) | [C++](./C++/eat-pizzas.cpp) [Python](./Python/eat-pizzas.py) | _O(nlogn)_   | _O(1)_        | Medium         | | Sort, Greedy
3458 | [Select K Disjoint Special Substrings](https://leetcode.com/problems/select-k-disjoint-special-substrings/) | [C++](./C++/select-k-disjoint-special-substrings.cpp) [Python](./Python/select-k-disjoint-special-substrings.py) | _O(n + 26^3)_   | _O(26)_        | Medium         | | Hash Table, Sort, Greedy
3462 | [Maximum Sum With at Most K Elements](https://leetcode.com/problems/maximum-sum-with-at-most-k-elements/) | [C++](./C++/maximum-sum-with-at-most-k-elements.cpp) [Python](./Python/maximum-sum-with-at-most-k-elements.py) | _O(n * m)_   | _O(1)_        | Medium         | | Greedy, Quick Select
3468 | [Find the Number of Copy Arrays](https://leetcode.com/problems/find-the-number-of-copy-arrays/) | [C++](./C++/find-the-number-of-copy-arrays.cpp) [Python](./Python/find-the-number-of-copy-arrays.py) | _O(n)_   | _O(1)_        | Medium         | | Greedy
3474 | [Lexicographically Smallest Generated String](https://leetcode.com/problems/lexicographically-smallest-generated-string/) | [C++](./C++/lexicographically-smallest-generated-string.cpp) [Python](./Python/lexicographically-smallest-generated-string.py) | _O(n + m)_   | _O(n + m)_        | Hard         | | `KMP Algorithm`, `Z-Function`, Two Pointers, Sliding Window, Deque, Greedy
3476 | [Maximize Profit from Task Assignment](https://leetcode.com/problems/maximize-profit-from-task-assignment/) | [C++](./C++/maximize-profit-from-task-assignment.cpp) [Python](./Python/maximize-profit-from-task-assignment.py) | _O(n + tlogt)_   | _O(n)_        | Medium         | 🔒 | Freq Table, Sort, Greedy
3478 | [Choose K Elements With Maximum Sum](https://leetcode.com/problems/choose-k-elements-with-maximum-sum/) | [C++](./C++/choose-k-elements-with-maximum-sum.cpp) [Python](./Python/choose-k-elements-with-maximum-sum.py) | _O(nlogn)_   | _O(n)_        | Medium         | | Sort, Greedy, Two Pointers, Heap
3480 | [Maximize Subarrays After Removing One Conflicting Pair](https://leetcode.com/problems/maximize-subarrays-after-removing-one-conflicting-pair/) | [C++](./C++/maximize-subarrays-after-removing-one-conflicting-pair.cpp) [Python](./Python/maximize-subarrays-after-removing-one-conflicting-pair.py) | _O(n + m)_   | _O(n + m)_        | Hard         | | Greedy
3494 | [Find the Minimum Amount of Time to Brew Potions](https://leetcode.com/problems/find-the-minimum-amount-of-time-to-brew-potions/) | [C++](./C++/find-the-minimum-amount-of-time-to-brew-potions.cpp) [Python](./Python/find-the-minimum-amount-of-time-to-brew-potions.py) | _O(n * m)_   | _O(1)_        | Medium         | | Prefix Sum, Greedy
3494 | [Find the Minimum Amount of Time to Brew Potions](https://leetcode.com/problems/find-the-minimum-amount-of-time-to-brew-potions/) | [C++](./C++/find-the-minimum-amount-of-time-to-brew-potions.cpp) [Python](./Python/find-the-minimum-amount-of-time-to-brew-potions.py) | _O(n * m)_   | _O(1)_        | Medium         | | Prefix Sum, Greedy
3495 | [Minimum Operations to Make Array Elements Zero](https://leetcode.com/problems/minimum-operations-to-make-array-elements-zero/) | [C++](./C++/minimum-operations-to-make-array-elements-zero.cpp) [Python](./Python/minimum-operations-to-make-array-elements-zero.py) | _O(qlogr)_   | _O(1)_        | Hard         | | Greedy
3496 | [Maximize Score After Pair Deletions](https://leetcode.com/problems/maximize-score-after-pair-deletions/) | [C++](./C++/maximize-score-after-pair-deletions.cpp) [Python](./Python/maximize-score-after-pair-deletions.py) | _O(n)_   | _O(1)_        | Medium         | 🔒 | Greedy
3499 | [Maximize Active Section with Trade I](https://leetcode.com/problems/maximize-active-section-with-trade-i/) | [C++](./C++/maximize-active-section-with-trade-i.cpp) [Python](./Python/maximize-active-section-with-trade-i.py) | _O(n)_   | _O(1)_        | Medium         | | Greedy
3501 | [Maximize Active Section with Trade II](https://leetcode.com/problems/maximize-active-section-with-trade-ii/) | [C++](./C++/maximize-active-section-with-trade-ii.cpp) [Python](./Python/maximize-active-section-with-trade-ii.py) | _O(nlogn + q)_   | _O(nlogn)_        | Hard         | | Greedy, RMQ, Sparse Table
3506 | [Find Time Required to Eliminate Bacterial Strains](https://leetcode.com/problems/find-time-required-to-eliminate-bacterial-strains/) | [C++](./C++/find-time-required-to-eliminate-bacterial-strains.cpp) [Python](./Python/find-time-required-to-eliminate-bacterial-strains.py) | _O(nlogn)_   | _O(1)_        | Hard         | 🔒 | Heap, Greedy
3511 | [Make a Positive Array](https://leetcode.com/problems/make-a-positive-array/) | [C++](./C++/make-a-positive-array.cpp) [Python](./Python/make-a-positive-array.py) | _O(n)_   | _O(1)_        | Medium         | 🔒 | Prefix Sum, Greedy
3517 | [Smallest Palindromic Rearrangement I](https://leetcode.com/problems/smallest-palindromic-rearrangement-i/) | [C++](./C++/smallest-palindromic-rearrangement-i.cpp) [Python](./Python/smallest-palindromic-rearrangement-i.py) | _O(n + 26)_   | _O(26)_        | Medium         | | Freq Table, Counting Sort, Greedy
3518 | [Smallest Palindromic Rearrangement II](https://leetcode.com/problems/smallest-palindromic-rearrangement-ii/) | [C++](./C++/smallest-palindromic-rearrangement-ii.cpp) [Python](./Python/smallest-palindromic-rearrangement-ii.py) | _O(26 * n)_   | _O(26)_        | Hard         | | Freq Table, Counting Sort, Greedy, Combinatorics
3523 | [Make Array Non-decreasing](https://leetcode.com/problems/make-array-non-decreasing/) | [C++](./C++/make-array-non-decreasing.cpp) [Python](./Python/make-array-non-decreasing.py) | _O(n)_   | _O(1)_        | Medium         | | Greedy
3542 | [Minimum Operations to Convert All Elements to Zero](https://leetcode.com/problems/minimum-operations-to-convert-all-elements-to-zero/) | [C++](./C++/minimum-operations-to-convert-all-elements-to-zero.cpp) [Python](./Python/minimum-operations-to-convert-all-elements-to-zero.py) | _O(n)_   | _O(n)_        | Medium         | | Greedy, Mono Stack
3545 | [Minimum Deletions for At Most K Distinct Characters](https://leetcode.com/problems/minimum-deletions-for-at-most-k-distinct-characters/) | [C++](./C++/minimum-deletions-for-at-most-k-distinct-characters.cpp) [Python](./Python/minimum-deletions-for-at-most-k-distinct-characters.py) | _O(n + 26)_   | _O(n + 26)_        | Easy         | | Freq Table, Counting Sort, Greedy
3557 | [Find Maximum Number of Non Intersecting Substrings](https://leetcode.com/problems/find-maximum-number-of-non-intersecting-substrings/) | [C++](./C++/find-maximum-number-of-non-intersecting-substrings.cpp) [Python](./Python/find-maximum-number-of-non-intersecting-substrings.py) | _O(n)_   | _O(26)_        | Medium         | | Greedy, Hash Table
3576 | [Transform Array to All Equal Elements](https://leetcode.com/problems/transform-array-to-all-equal-elements/) | [C++](./C++/transform-array-to-all-equal-elements.cpp) [Python](./Python/transform-array-to-all-equal-elements.py) | _O(n)_   | _O(1)_        | Medium         | | Greedy
3587 | [Minimum Adjacent Swaps to Alternate Parity](https://leetcode.com/problems/minimum-adjacent-swaps-to-alternate-parity/) | [C++](./C++/minimum-adjacent-swaps-to-alternate-parity.cpp) [Python](./Python/minimum-adjacent-swaps-to-alternate-parity.py) | _O(n)_   | _O(1)_        | Medium         | | Greedy
3627 | [Maximum Median Sum of Subsequences of Size 3](https://leetcode.com/problems/maximum-median-sum-of-subsequences-of-size-3/) | [C++](./C++/maximum-median-sum-of-subsequences-of-size-3.cpp) [Python](./Python/maximum-median-sum-of-subsequences-of-size-3.py) | _O(nlogn)_   | _O(1)_        | Medium         | | Sort, Greedy
3630 | [Partition Array for Maximum XOR and AND](https://leetcode.com/problems/partition-array-for-maximum-xor-and-and/) | [C++](./C++/partition-array-for-maximum-xor-and-and.cpp) [Python](./Python/partition-array-for-maximum-xor-and-and.py) | _O(nlogr * 2^n)_   | _O(1)_        | Hard         | | Bitmasks, Greedy
3633 | [Earliest Finish Time for Land and Water Rides I](https://leetcode.com/problems/earliest-finish-time-for-land-and-water-rides-i/) | [C++](./C++/earliest-finish-time-for-land-and-water-rides-i.cpp) [Python](./Python/earliest-finish-time-for-land-and-water-rides-i.py) | _O(n)_   | _O(1)_        | Easy         | | Greedy
3635 | [Earliest Finish Time for Land and Water Rides II](https://leetcode.com/problems/earliest-finish-time-for-land-and-water-rides-ii/) | [C++](./C++/earliest-finish-time-for-land-and-water-rides-ii.cpp) [Python](./Python/earliest-finish-time-for-land-and-water-rides-ii.py) | _O(n)_   | _O(1)_        | Medium         | | Greedy
3638 | [Maximum Balanced Shipments](https://leetcode.com/problems/maximum-balanced-shipments/) | [C++](./C++/maximum-balanced-shipments.cpp) [Python](./Python/maximum-balanced-shipments.py) | _O(n)_   | _O(1)_        | Medium         | | Greedy
3645 | [Maximum Total from Optimal Activation Order](https://leetcode.com/problems/maximum-total-from-optimal-activation-order/) | [C++](./C++/maximum-total-from-optimal-activation-order.cpp) [Python](./Python/maximum-total-from-optimal-activation-order.py) | _O(nlogn)_   | _O(n)_        | Medium         | | Sort, Greedy
3675 | [Minimum Operations to Transform String](https://leetcode.com/problems/minimum-operations-to-transform-string/) | [C++](./C++/minimum-operations-to-transform-string.cpp) [Python](./Python/minimum-operations-to-transform-string.py) | _O(n)_   | _O(1)_        | Medium         | | Greedy
3681 | [Maximum XOR of Subsequences](https://leetcode.com/problems/maximum-xor-of-subsequences/) | [C++](./C++/maximum-xor-of-subsequences.cpp) [Python](./Python/maximum-xor-of-subsequences.py) | _O(nlogr)_   | _O(r)_        | Hard         | | Bitmasks, Greedy
3689 | [Maximum Total Subarray Value I](https://leetcode.com/problems/maximum-total-subarray-value-i/) | [C++](./C++/maximum-total-subarray-value-i.cpp) [Python](./Python/maximum-total-subarray-value-i.py) | _O(n)_   | _O(1)_        | Medium         | | Greedy
3711 | [Maximum Transactions Without Negative Balance](https://leetcode.com/problems/maximum-transactions-without-negative-balance/) | [C++](./C++/maximum-transactions-without-negative-balance.cpp) [Python](./Python/maximum-transactions-without-negative-balance.py) | _O(nlogn)_   | _O(n)_        | Medium         | 🔒 | Greedy, Heap
3720 | [Lexicographically Smallest Permutation Greater Than Target](https://leetcode.com/problems/lexicographically-smallest-permutation-greater-than-target/) | [C++](./C++/lexicographically-smallest-permutation-greater-than-target.cpp) [Python](./Python/lexicographically-smallest-permutation-greater-than-target.py) | _O(26 * n)_   | _O(26)_        | Medium         | | Freq Table, Greedy
3723 | [Maximize Sum of Squares of Digits](https://leetcode.com/problems/maximize-sum-of-squares-of-digits/) | [C++](./C++/maximize-sum-of-squares-of-digits.cpp) [Python](./Python/maximize-sum-of-squares-of-digits.py) | _O(n)_   | _O(1)_        | Medium         | | Greedy
3724 | [Minimum Operations to Transform Array](https://leetcode.com/problems/minimum-operations-to-transform-array/) | [C++](./C++/minimum-operations-to-transform-array.cpp) [Python](./Python/minimum-operations-to-transform-array.py) | _O(n)_   | _O(1)_        | Medium         | | Greedy
3727 | [Maximum Alternating Sum of Squares](https://leetcode.com/problems/maximum-alternating-sum-of-squares/) | [C++](./C++/maximum-alternating-sum-of-squares.cpp) [Python](./Python/maximum-alternating-sum-of-squares.py) | _O(n)_   | _O(n)_        | Medium         | | Greedy, Sort, Quick Select
3730 | [Maximum Calories Burnt from Jumps](https://leetcode.com/problems/maximum-calories-burnt-from-jumps/) | [C++](./C++/maximum-calories-burnt-from-jumps.cpp) [Python](./Python/maximum-calories-burnt-from-jumps.py) | _O(nlogn)_   | _O(1)_        | Medium         | 🔒 | Greedy, Sort
3732 | [Maximum Product of Three Elements After One Replacement](https://leetcode.com/problems/maximum-product-of-three-elements-after-one-replacement/) | [C++](./C++/maximum-product-of-three-elements-after-one-replacement.cpp) [Python](./Python/maximum-product-of-three-elements-after-one-replacement.py) | _O(n)_   | _O(1)_        | Medium         | | Greedy
3734 | [Lexicographically Smallest Palindromic Permutation Greater Than Target](https://leetcode.com/problems/lexicographically-smallest-palindromic-permutation-greater-than-target/) | [C++](./C++/lexicographically-smallest-palindromic-permutation-greater-than-target.cpp) [Python](./Python/lexicographically-smallest-palindromic-permutation-greater-than-target.py) | _O(26 * n)_   | _O(26)_        | Hard         | | Freq Table, Greedy
3752 | [Lexicographically Smallest Negated Permutation that Sums to Target](https://leetcode.com/problems/lexicographically-smallest-negated-permutation-that-sums-to-target/) | [C++](./C++/lexicographically-smallest-negated-permutation-that-sums-to-target.cpp) [Python](./Python/lexicographically-smallest-negated-permutation-that-sums-to-target.py) | _O(n)_   | _O(1)_        | Medium         | | Greedy, Two Pointers
3763 | [Maximum Total Sum with Threshold Constraints](https://leetcode.com/problems/maximum-total-sum-with-threshold-constraints/) | [C++](./C++/maximum-total-sum-with-threshold-constraints.cpp) [Python](./Python/maximum-total-sum-with-threshold-constraints.py) | _O(n)_   | _O(n)_        | Medium         | 🔒 | Sort, Counting Sort, Greedy
3767 | [Maximize Points After Choosing K Tasks](https://leetcode.com/problems/maximize-points-after-choosing-k-tasks/) | [C++](./C++/maximize-points-after-choosing-k-tasks.cpp) [Python](./Python/maximize-points-after-choosing-k-tasks.py) | _O(n)_   | _O(n)_        | Medium         | | Greedy, Sort, Quick Select
3776 | [Minimum Moves to Balance Circular Array](https://leetcode.com/problems/minimum-moves-to-balance-circular-array/) | [C++](./C++/minimum-moves-to-balance-circular-array.cpp) [Python](./Python/minimum-moves-to-balance-circular-array.py) | _O(n)_   | _O(1)_        | Medium         | | Greedy
3785 | [Minimum Swaps to Avoid Forbidden Values](https://leetcode.com/problems/minimum-swaps-to-avoid-forbidden-values/) | [C++](./C++/minimum-swaps-to-avoid-forbidden-values.cpp) [Python](./Python/minimum-swaps-to-avoid-forbidden-values.py) | _O(n)_ | _O(1)_ | Hard | | `Boyer–Moore Majority Vote Algorithm`, Freq Table, Greedy
3796 | [Find Maximum Value in a Constrained Sequence](https://leetcode.com/problems/find-maximum-value-in-a-constrained-sequence/) | [C++](./C++/find-maximum-value-in-a-constrained-sequence.cpp) [Python](./Python/find-maximum-value-in-a-constrained-sequence.py) | _O(n)_ | _O(n)_ | Medium | | Greedy, DP
3797 | [Count Routes to Climb a Rectangular Grid](https://leetcode.com/problems/count-routes-to-climb-a-rectangular-grid/) | [C++](./C++/count-routes-to-climb-a-rectangular-grid.cpp) [Python](./Python/count-routes-to-climb-a-rectangular-grid.py) | _O(n * m)_ | _O(m)_ | Hard | | DP, Two Pointers
3806 | [Maximum Bitwise AND After Increment Operations](https://leetcode.com/problems/maximum-bitwise-and-after-increment-operations/) | [C++](./C++/maximum-bitwise-and-after-increment-operations.cpp) [Python](./Python/maximum-bitwise-and-after-increment-operations.py) | _O(nlogr)_ | _O(n)_ | Hard | | Bitmasks, Greedy, Sort, Quick Select
3812 | [Minimum Edge Toggles on a Tree](https://leetcode.com/problems/minimum-edge-toggles-on-a-tree/) | [C++](./C++/minimum-edge-toggles-on-a-tree.cpp) [Python](./Python/minimum-edge-toggles-on-a-tree.py) | _O(n)_ | _O(n)_ | Hard | | Greedy, Topological Sort, Bitmasks
3816 | [Lexicographically Smallest String After Deleting Duplicate Characters](https://leetcode.com/problems/lexicographically-smallest-string-after-deleting-duplicate-characters/) | [C++](./C++/lexicographically-smallest-string-after-deleting-duplicate-characters.cpp) [Python](./Python/lexicographically-smallest-string-after-deleting-duplicate-characters.py) | _O(n + 26)_ | _O(26)_ | Hard | | Freq Table, Greedy
3828 | [Final Element After Subarray Deletions](https://leetcode.com/problems/final-element-after-subarray-deletions/) | [C++](./C++/final-element-after-subarray-deletions.cpp) [Python](./Python/final-element-after-subarray-deletions.py) | _O(1)_ | _O(1)_ | Medium | | Greedy, Game Theory
3849 | [Maximum Bitwise XOR After Rearrangement](https://leetcode.com/problems/maximum-bitwise-xor-after-rearrangement/) | [C++](./C++/maximum-bitwise-xor-after-rearrangement.cpp) [Python](./Python/maximum-bitwise-xor-after-rearrangement.py) | _O(n)_ | _O(1)_ | Medium | | Greedy
3854 | [Minimum Operations to Make Array Parity Alternating](https://leetcode.com/problems/minimum-operations-to-make-array-parity-alternating/) | [C++](./C++/minimum-operations-to-make-array-parity-alternating.cpp) [Python](./Python/minimum-operations-to-make-array-parity-alternating.py) | _O(n)_ | _O(1)_ | Medium | | Greedy
3858 | [Minimum Bitwise OR From Grid](https://leetcode.com/problems/minimum-bitwise-or-from-grid/) | [C++](./C++/minimum-bitwise-or-from-grid.cpp) [Python](./Python/minimum-bitwise-or-from-grid.py) | _O(nlogr)_ | _O(1)_ | Medium | | Bitmasks, Greedy
3863 | [Minimum Operations to Sort a String](https://leetcode.com/problems/minimum-operations-to-sort-a-string/) | [C++](./C++/minimum-operations-to-sort-a-string.cpp) [Python](./Python/minimum-operations-to-sort-a-string.py) | _O(n)_ | _O(1)_ | Medium | | Greedy
3868 | [Minimum Cost to Equalize Arrays Using Swaps](https://leetcode.com/problems/minimum-cost-to-equalize-arrays-using-swaps/) | [C++](./C++/minimum-cost-to-equalize-arrays-using-swaps.cpp) [Python](./Python/minimum-cost-to-equalize-arrays-using-swaps.py) | _O(n)_ | _O(n)_ | Medium | | Freq Table, Greedy
3888 | [Minimum Operations to Make All Grid Elements Equal](https://leetcode.com/problems/minimum-operations-to-make-all-grid-elements-equal/) | [C++](./C++/minimum-operations-to-make-all-grid-elements-equal.cpp) [Python](./Python/minimum-operations-to-make-all-grid-elements-equal.py) | _O(m * n)_ | _O(k * n)_ | Hard | 🔒 | Sliding Window, Greedy, Difference Array
3892 | [Minimum Operations to Achieve At Least K Peaks](https://leetcode.com/problems/minimum-operations-to-achieve-at-least-k-peaks/) | [C++](./C++/minimum-operations-to-achieve-at-least-k-peaks.cpp) [Python](./Python/minimum-operations-to-achieve-at-least-k-peaks.py) | _O(n + klogn)_ | _O(n)_ | Hard | | Greedy, Heap, Doubly Linked List
3897 | [Maximum Value of Concatenated Binary Segments](https://leetcode.com/problems/maximum-value-of-concatenated-binary-segments/) | [C++](./C++/maximum-value-of-concatenated-binary-segments.cpp) [Python](./Python/maximum-value-of-concatenated-binary-segments.py) | _O(r + nlogn)_ | _O(r + n)_ | Hard | | Greedy
3914 | [Minimum Operations to Make Array Non Decreasing](https://leetcode.com/problems/minimum-operations-to-make-array-non-decreasing/) | [C++](./C++/minimum-operations-to-make-array-non-decreasing.cpp) [Python](./Python/minimum-operations-to-make-array-non-decreasing.py) | _O(n)_ | _O(1)_ | Medium | | Greedy
3919 | [Minimum Cost to Move Between Indices](https://leetcode.com/problems/minimum-cost-to-move-between-indices/) | [C++](./C++/minimum-cost-to-move-between-indices.cpp) [Python](./Python/minimum-cost-to-move-between-indices.py) | _O(n)_ | _O(n)_ | Medium | | Greedy, Prefix Sum
3922 | [Minimum Flips to Make Binary String Coherent](https://leetcode.com/problems/minimum-flips-to-make-binary-string-coherent/) | [C++](./C++/minimum-flips-to-make-binary-string-coherent.cpp) [Python](./Python/minimum-flips-to-make-binary-string-coherent.py) | _O(n)_ | _O(1)_ | Medium | | Greedy, Case Works
3947 | [Maximum Number of Items From Sale II](https://leetcode.com/problems/maximum-number-of-items-from-sale-ii/) | [C++](./C++/maximum-number-of-items-from-sale-ii.cpp) [Python](./Python/maximum-number-of-items-from-sale-ii.py) | _O(nlogn)_ | _O(n)_ | Medium | | Freq Table, Sort, Greedy
3948 | [Lexicographically Maximum MEX Array](https://leetcode.com/problems/lexicographically-maximum-mex-array/) | [C++](./C++/lexicographically-maximum-mex-array.cpp) [Python](./Python/lexicographically-maximum-mex-array.py) | _O(n)_ | _O(n)_ | Hard | | Hash Table, Freq Table, Prefix Sum, Greedy
3952 | [Maximum Total Value of Covered Indices](https://leetcode.com/problems/maximum-total-value-of-covered-indices/) | [C++](./C++/maximum-total-value-of-covered-indices.cpp) [Python](./Python/maximum-total-value-of-covered-indices.py) | _O(n)_ | _O(1)_ | Medium | | Greedy, DP
3961 | [Maximize Sum of Device Ratings](https://leetcode.com/problems/maximize-sum-of-device-ratings/) | [C++](./C++/maximize-sum-of-device-ratings.cpp) [Python](./Python/maximize-sum-of-device-ratings.py) | _O(m * n)_ | _O(1)_ | Medium | | Greedy
3964 | [Minimum Lights to Illuminate a Road](https://leetcode.com/problems/minimum-lights-to-illuminate-a-road/) | [C++](./C++/minimum-lights-to-illuminate-a-road.cpp) [Python](./Python/minimum-lights-to-illuminate-a-road.py) | _O(n)_ | _O(n)_ | Medium | | Difference Array, Greedy
3974 | [Maximum Total Sum of K Selected Elements](https://leetcode.com/problems/maximum-total-sum-of-k-selected-elements/) | [C++](./C++/maximum-total-sum-of-k-selected-elements.cpp) [Python](./Python/maximum-total-sum-of-k-selected-elements.py) | _O(nlogk)_ | _O(k)_ | Medium | | Sort, Greedy
3980 | [Minimum Operations to Transform Binary String](https://leetcode.com/problems/minimum-operations-to-transform-binary-string/) | [C++](./C++/minimum-operations-to-transform-binary-string.cpp) [Python](./Python/minimum-operations-to-transform-binary-string.py) | _O(n)_ | _O(1)_ | Medium | | Greedy
3994 | [Minimum Adjacent Swaps to Partition Array](https://leetcode.com/problems/minimum-adjacent-swaps-to-partition-array/) | [C++](./C++/minimum-adjacent-swaps-to-partition-array.cpp) [Python](./Python/minimum-adjacent-swaps-to-partition-array.py) | _O(n)_ | _O(1)_ | Medium | | Greedy
4000 | [Largest Integer With Given Digit Sum](https://leetcode.com/problems/largest-integer-with-given-digit-sum/) | [C++](./C++/largest-integer-with-given-digit-sum.cpp) [Python](./Python/largest-integer-with-given-digit-sum.py) | _O(n)_ | _O(1)_ | Easy | | Greedy
4014 | [Minimum Total Price After Applying Discounts](https://leetcode.com/problems/minimum-total-price-after-applying-discounts/) | [C++](./C++/minimum-total-price-after-applying-discounts.cpp) [Python](./Python/minimum-total-price-after-applying-discounts.py) | _O(nlogn + mlogm)_ | _O(1)_ | Medium | | Sort, Greedy
4019 | [Merge Close Characters II](https://leetcode.com/problems/merge-close-characters-ii/) | [C++](./C++/merge-close-characters-ii.cpp) [Python](./Python/merge-close-characters-ii.py) | _O(n)_ | _O(n)_ | Medium | 🔒 | Greedy, Hash Table



    **[⬆️ Back to Top](#algorithms)**



## Graph
|  #  | Title           |  Solution       |  Time           | Space           | Difficulty    | Tag          | Note| 
|-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------|-----|
3108 | [Minimum Cost Walk in Weighted Graph](https://leetcode.com/problems/minimum-cost-walk-in-weighted-graph/) | [C++](./C++/minimum-cost-walk-in-weighted-graph.cpp) [Python](./Python/minimum-cost-walk-in-weighted-graph.py) | _O(n + e + q)_ | _O(n)_ | Hard | | Union Find
3112 | [Minimum Time to Visit Disappearing Nodes](https://leetcode.com/problems/find-the-closest-marked-node/)  | [C++](./C++/minimum-time-to-visit-disappearing-nodes.cpp) [Python](./Python/minimum-time-to-visit-disappearing-nodes.py) |  _O(\|E\| * log\|V\|)_ | _O(\|E\|)_ | Medium           | | Graph, `Dijkstra's Algorithm` |
3123 | [Find Edges in Shortest Paths](https://leetcode.com/problems/find-edges-in-shortest-paths/)  | [C++](./C++/find-edges-in-shortest-paths.cpp) [Python](./Python/find-edges-in-shortest-paths.py) |  _O(\|E\| * log\|V\|)_ | _O(\|E\|)_ | Hard           | | Graph, `Dijkstra's Algorithm` |
3235 | [Check if the Rectangle Corner Is Reachable](https://leetcode.com/problems/check-if-the-rectangle-corner-is-reachable/)  | [C++](./C++/check-if-the-rectangle-corner-is-reachable.cpp) [Python](./Python/check-if-the-rectangle-corner-is-reachable.py) |  _O(n^2)_ | _O(n)_ | Hard           | | Graph, BFS, DFS, Union Find |
3243 | [Shortest Distance After Road Addition Queries I](https://leetcode.com/problems/shortest-distance-after-road-addition-queries-i/)  | [C++](./C++/shortest-distance-after-road-addition-queries-i.cpp) [Python](./Python/shortest-distance-after-road-addition-queries-i.py) |  _O(n^2)_ | _O(n^2)_ | Medium           | | Graph, `Dijkstra's Algorithm`, BFS |
3244 | [Shortest Distance After Road Addition Queries II](https://leetcode.com/problems/shortest-distance-after-road-addition-queries-ii/)  | [C++](./C++/shortest-distance-after-road-addition-queries-ii.cpp) [Python](./Python/shortest-distance-after-road-addition-queries-ii.py) |  _O(nlogn)_ | _O(n)_ | Hard           | | Graph, BST, Sorted List |
3265 | [Count Almost Equal Pairs I](https://leetcode.com/problems/count-almost-equal-pairs-i/) | [C++](./C++/count-almost-equal-pairs-i.cpp) [Python](./Python/count-almost-equal-pairs-i.py) | _O(n * l^2)_ | _O(n)_ | Medium | | Freq Table, Combinatorics, Graph, BFS |
3267 | [Count Almost Equal Pairs II](https://leetcode.com/problems/count-almost-equal-pairs-ii/) | [C++](./C++/count-almost-equal-pairs-ii.cpp) [Python](./Python/count-almost-equal-pairs-ii.py) | _O(n * l^4)_ | _O(n)_ | Hard | | Freq Table, Combinatorics, Graph, BFS |
3276 | [Select Cells in Grid With Maximum Score](https://leetcode.com/problems/select-cells-in-grid-with-maximum-score/) | [C++](./C++/select-cells-in-grid-with-maximum-score.cpp) [Python](./Python/select-cells-in-grid-with-maximum-score.py) | _O(n^2 * max(n, r))_ | _O(n * max(n, r))_ | Hard | variant of [Maximum Compatibility Score Sum](https://leetcode.com/problems/maximum-compatibility-score-sum/) | `Hungarian Weighted Bipartite Matching`, DP, Bitmasks |
3310 | [Remove Methods From Project](https://leetcode.com/problems/remove-methods-from-project/)| [C++](./C++/remove-methods-from-project.cpp) [Python](./Python/remove-methods-from-project.py)| _O(n + e)_ | _O(n + e)_ | Medium | | Graph, BFS |
3341 | [Find Minimum Time to Reach Last Room I](https://leetcode.com/problems/find-minimum-time-to-reach-last-room-i/)  | [C++](./C++/find-minimum-time-to-reach-last-room-i.cpp) [Python](./Python/find-minimum-time-to-reach-last-room-i.py) |  _O(n * m * log(n * m))_ | _O(n * m)_ | Medium           | | Graph, `Dijkstra's Algorithm` |
3342 | [Find Minimum Time to Reach Last Room II](https://leetcode.com/problems/find-minimum-time-to-reach-last-room-ii/)  | [C++](./C++/find-minimum-time-to-reach-last-room-ii.cpp) [Python](./Python/find-minimum-time-to-reach-last-room-ii.py) |  _O(n * m * log(n * m))_ | _O(n * m)_ | Medium           | | Graph, `Dijkstra's Algorithm` |
3377 | [Digit Operations to Make Two Integers Equal](https://leetcode.com/problems/digit-operations-to-make-two-integers-equal/)  | [C++](./C++/digit-operations-to-make-two-integers-equal.cpp) [Python](./Python/digit-operations-to-make-two-integers-equal.py) |  _O(nlogn)_ | _O(n)_ | Medium           | | Graph, Number Theory, `Linear Sieve of Eratosthenes`, `Dijkstra's Algorithm` |
3378 | [Count Connected Components in LCM Graph](https://leetcode.com/problems/count-connected-components-in-lcm-graph/) | [C++](./C++/count-connected-components-in-lcm-graph.cpp) [Python](./Python/count-connected-components-in-lcm-graph.py) | _O(n + tlogt)_ | _O(t)_ | Hard | | Number Theory, Graph, Union Find |
3383 | [Minimum Runes to Add to Cast Spell](https://leetcode.com/problems/minimum-runes-to-add-to-cast-spell/) | [C++](./C++/minimum-runes-to-add-to-cast-spell.cpp) [Python](./Python/minimum-runes-to-add-to-cast-spell.py) | _O(n)_ | _O(n)_ | Hard | 🔒 | Graph, `Tarjan's Strongly Connected Components Algorithm`, SCC |
3376 | [Minimum Time to Break Locks I](https://leetcode.com/problems/minimum-time-to-break-locks-i/) | [C++](./C++/minimum-time-to-break-locks-i.cpp) [Python](./Python/minimum-time-to-break-locks-i.py) | _O(n^3)_ | _O(n^2)_ | Medium | | Bitmasks, DP, Graph, `Hungarian Weighted Bipartite Matching`
3385 | [Minimum Time to Break Locks II](https://leetcode.com/problems/minimum-time-to-break-locks-ii/) | [C++](./C++/minimum-time-to-break-locks-ii.cpp) [Python](./Python/minimum-time-to-break-locks-ii.py) | _O(n^3)_ | _O(n^2)_ | Hard | 🔒 | Graph, `Hungarian Weighted Bipartite Matching`
3387 | [Maximize Amount After Two Days of Conversions](https://leetcode.com/problems/maximize-amount-after-two-days-of-conversions/) | [C++](./C++/maximize-amount-after-two-days-of-conversions.cpp) [Python](./Python/maximize-amount-after-two-days-of-conversions.py) | _O(n^2)_ | _O(n)_ | Medium | | `Bellman-Ford Algorithm`, BFS |
3419 | [Minimize the Maximum Edge Weight of Graph](https://leetcode.com/problems/minimize-the-maximum-edge-weight-of-graph/)  | [C++](./C++/minimize-the-maximum-edge-weight-of-graph.cpp) [Python](./Python/minimize-the-maximum-edge-weight-of-graph.py) |  _O(nlogn + e)_ | _O(n + e)_ | Medium           | | Graph, `Dijkstra's Algorithm`, `Prim's Algorithm`, Binary Search, BFS |
3435 | [Frequencies of Shortest Supersequences](https://leetcode.com/problems/frequencies-of-shortest-supersequences/) | [C++](./C++/frequencies-of-shortest-supersequences.cpp)  [Python](./Python/frequencies-of-shortest-supersequences.py)  | _O(n + k^2 * 2^k)_ | _O(k^2)_ | Hard         | | Bitmasks, Graph, Topological Sort |
3481 | [Apply Substitutions](https://leetcode.com/problems/apply-substitutions/) | [C++](./C++/apply-substitutions.cpp)  [Python](./Python/apply-substitutions.py)  | _O(r * 2^r)_ | _O(r * 2^r)_ | Medium         | 🔒 | Graph, Topological Sort, Memoization |
3493 | [Properties Graph](https://leetcode.com/problems/properties-graph/)  | [C++](./C++/properties-graph.cpp) [Python](./Python/properties-graph.py) |  _O(n^2 * m)_ | _O(n)_ | Medium           | | Graph, Flood Fill, BFS, Union Find |
3532 | [Path Existence Queries in a Graph I](https://leetcode.com/problems/path-existence-queries-in-a-graph-i/) | [C++](./C++/path-existence-queries-in-a-graph-i.cpp) [Python](./Python/path-existence-queries-in-a-graph-i.py) | _O(n + q)_ | _O(n)_ | Medium | | Prefix Sum
3534 | [Path Existence Queries in a Graph II](https://leetcode.com/problems/path-existence-queries-in-a-graph-ii/) | [C++](./C++/path-existence-queries-in-a-graph-ii.cpp) [Python](./Python/path-existence-queries-in-a-graph-ii.py) | _O((n + q) * logn)_ | _O(nlogn)_ | Hard | | Prefix Sum, Greedy, Binary Lifting
3536 | [Maximum Product of Two Digits](https://leetcode.com/problems/maximum-product-of-two-digits/) | [C++](./C++/maximum-product-of-two-digits.cpp) [Python](./Python/maximum-product-of-two-digits.py) | _O(d + 10)_ | _O(10)_ | Easy | | Freq Table, Greedy
3547 | [Maximum Sum of Edge Values in a Graph](https://leetcode.com/problems/maximum-sum-of-edge-values-in-a-graph/) | [C++](./C++/maximum-sum-of-edge-values-in-a-graph.cpp) [Python](./Python/maximum-sum-of-edge-values-in-a-graph.py) | _O(n)_ | _O(n)_ | Hard | | Flood Fill, BFS, Counting Sort, Greedy
3594 | [Minimum Time to Transport All Individuals](https://leetcode.com/problems/minimum-time-to-transport-all-individuals/) | [C++](./C++/minimum-time-to-transport-all-individuals.cpp) [Python](./Python/minimum-time-to-transport-all-individuals.py) | _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](https://leetcode.com/problems/maximize-spanning-tree-stability-with-upgrades/) | [C++](./C++/maximize-spanning-tree-stability-with-upgrades.cpp) [Python](./Python/maximize-spanning-tree-stability-with-upgrades.py) | _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](https://leetcode.com/problems/minimum-time-to-reach-destination-in-directed-graph/) | [C++](./C++/minimum-time-to-reach-destination-in-directed-graph.cpp) [Python](./Python/minimum-time-to-reach-destination-in-directed-graph.py) | _O(n + elogn)_ | _O(n + e)_ | Medium | | Graph, `Dijkstra's Algorithm`
3620 | [Network Recovery Pathways](https://leetcode.com/problems/network-recovery-pathways/)|[C++](./C++/network-recovery-pathways.cpp) [Python](./Python/network-recovery-pathways.py) | _O((n + e) * logr)_      | _O(n + e)_          | Hard         | | Binary Search, Topological Sort, DP
3650 | [Minimum Cost Path with Edge Reversals](https://leetcode.com/problems/minimum-cost-path-with-edge-reversals/) | [C++](./C++/minimum-cost-path-with-edge-reversals.cpp) [Python](./Python/minimum-cost-path-with-edge-reversals.py) | _O(n + elogn)_ | _O(n + e)_ | Medium | | Graph, `Dijkstra's Algorithm`
3656 | [Determine if a Simple Graph Exists](https://leetcode.com/problems/determine-if-a-simple-graph-exists/) | [C++](./C++/determine-if-a-simple-graph-exists.cpp)  [Python](./Python/determine-if-a-simple-graph-exists.py)  | _O(nlogn)_ | _O(1)_ | Medium         | 🔒 | Graph, `Erdős–Gallai Theorem`, Sort, Prefix sum, Two Pointers
3660 | [Jump Game IX](https://leetcode.com/problems/jump-game-ix/) | [C++](./C++/jump-game-ix.cpp) [Python](./Python/jump-game-ix.py) | _O(n)_ | _O(1)_ | Medium | | Graph, Prefix Sum
3710 | [Maximum Partition Factor](https://leetcode.com/problems/maximum-partition-factor/) | [C++](./C++/maximum-partition-factor.cpp) [Python](./Python/maximum-partition-factor.py) | _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](https://leetcode.com/problems/minimum-distance-excluding-one-maximum-weighted-edge/) | [C++](./C++/minimum-distance-excluding-one-maximum-weighted-edge.cpp) [Python](./Python/minimum-distance-excluding-one-maximum-weighted-edge.py) | _O(n + elogn)_ | _O(n + e)_ | Medium | 🔒 | Graph, `Dijkstra's Algorithm`
3873 | [Maximum Points Activated with One Addition](https://leetcode.com/problems/maximum-points-activated-with-one-addition/) | [C++](./C++/maximum-points-activated-with-one-addition.cpp) [Python](./Python/maximum-points-activated-with-one-addition.py) | _O(n)_ | _O(n)_ | Hard | | Graph, Union Find
3887 | [Incremental Even-Weighted Cycle Queries](https://leetcode.com/problems/incremental-even-weighted-cycle-queries/) | [C++](./C++/incremental-even-weighted-cycle-queries.cpp) [Python](./Python/incremental-even-weighted-cycle-queries.py) | _O(n + e)_ | _O(n)_ | Hard | | Graph, Union Find
3910 | [Count Connected Subgraphs with Even Node Sum](https://leetcode.com/problems/count-connected-subgraphs-with-even-node-sum/) | [C++](./C++/count-connected-subgraphs-with-even-node-sum.cpp) [Python](./Python/count-connected-subgraphs-with-even-node-sum.py) | _O((n + e) * 2^n)_ | _O(n + e)_ | Hard | | Graph, Bitmask, DFS
3928 | [Minimum Cost to Buy Apples II](https://leetcode.com/problems/minimum-cost-to-buy-apples-ii/) | [C++](./C++/minimum-cost-to-buy-apples-ii.cpp) [Python](./Python/minimum-cost-to-buy-apples-ii.py) | _O(n * (n + elogn))_ | _O(n + e)_ | Hard | | Graph, `Dijkstra's Algorithm`
3970 | [Shortest Path With At Most K Consecutive Identical Characters](https://leetcode.com/problems/shortest-path-with-at-most-k-consecutive-identical-characters/) | [C++](./C++/shortest-path-with-at-most-k-consecutive-identical-characters.cpp) [Python](./Python/shortest-path-with-at-most-k-consecutive-identical-characters.py) | _O(e * k * log(n * k))_ | _O(n * k + e)_ | Medium | | Graph, `Dijkstra's Algorithm`
3977 | [Minimum Time to Reach Target With Limited Power](https://leetcode.com/problems/minimum-time-to-reach-target-with-limited-power/) | [C++](./C++/minimum-time-to-reach-target-with-limited-power.cpp) [Python](./Python/minimum-time-to-reach-target-with-limited-power.py) | _O((n * p + e * p) * log(n * p))_ | _O(n * p)_ | Hard | | Graph, `Dijkstra's Algorithm`
4003 | [Minimum Cost Path with Alternating Directions III](https://leetcode.com/problems/minimum-cost-path-with-alternating-directions-iii/) | [C++](./C++/minimum-cost-path-with-alternating-directions-iii.cpp) [Python](./Python/minimum-cost-path-with-alternating-directions-iii.py) | _O((m * n) * log(m * n))_ | _O(m * n)_ | Hard | | Graph, `Dijkstra's Algorithm`



    **[⬆️ Back to Top](#algorithms)**



## Geometry
|  #  | Title           |  Solution       |  Time           | Space           | Difficulty    | Tag          | Note| 
|-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------|-----|
3453 | [Separate Squares I](https://leetcode.com/problems/separate-squares-i/) | [C++](./C++/separate-squares-i.cpp) [Python](./Python/separate-squares-i.py) | _O(nlogn)_ | _O(n)_ | Medium | | Binary Search, Sort, Line Sweep
3454 | [Separate Squares II](https://leetcode.com/problems/separate-squares-ii/) | [C++](./C++/separate-squares-ii.cpp) [Python](./Python/separate-squares-ii.py) | _O(nlogn)_ | _O(n)_ | Hard | | Sort, Line Sweep, Segment Tree



    **[⬆️ Back to Top](#algorithms)**



## Simulation
|  #  | Title           |  Solution       |  Time           | Space           | Difficulty    | Tag          | Note| 
|-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------|-----|
3100 | [Water Bottles II](https://leetcode.com/problems/water-bottles-ii/) | [C++](./C++/water-bottles-ii.cpp) [Python](./Python/water-bottles-ii.py) | _O(sqrt(n))_ | _O(1)_ | Medium | | Simulation
3168 | [Minimum Number of Chairs in a Waiting Room](https://leetcode.com/problems/minimum-number-of-chairs-in-a-waiting-room/) | [C++](./C++/minimum-number-of-chairs-in-a-waiting-room.cpp) [Python](./Python/minimum-number-of-chairs-in-a-waiting-room.py) | _O(n)_ | _O(1)_ | Easy | | Simulation
3175 | [Find The First Player to win K Games in a Row](https://leetcode.com/problems/find-the-first-player-to-win-k-games-in-a-row/) | [C++](./C++/find-the-first-player-to-win-k-games-in-a-row.cpp) [Python](./Python/find-the-first-player-to-win-k-games-in-a-row.py) | _O(n)_ | _O(1)_ | Medium | | Simulation
3248 | [Snake in Matrix](https://leetcode.com/problems/snake-in-matrix/) | [C++](./C++/snake-in-matrix.cpp) [Python](./Python/snake-in-matrix.py) | _O(c)_ | _O(1)_ | Medium | | Simulation
3412 | [Find Mirror Score of a String](https://leetcode.com/problems/find-mirror-score-of-a-string/) | [C++](./C++/find-mirror-score-of-a-string.cpp) [Python](./Python/find-mirror-score-of-a-string.py) | _O(n + 26)_ | _O(n + 26)_ | Medium | | Simulation, Hash Table, Stack
3433 | [Count Mentions Per User](https://leetcode.com/problems/count-mentions-per-user/) | [C++](./C++/count-mentions-per-user.cpp) [Python](./Python/count-mentions-per-user.py) | _O(eloge + e * n)_ | _O(e + n)_ | Medium | | Simulation
3507 | [Minimum Pair Removal to Sort Array I](https://leetcode.com/problems/minimum-pair-removal-to-sort-array-i/) | [C++](./C++/minimum-pair-removal-to-sort-array-i.cpp) [Python](./Python/minimum-pair-removal-to-sort-array-i.py) | _O(nlogn)_ | _O(n)_ | Easy | | Simulation, Doubly Linked List, Sorted List, BST
3510 | [Minimum Pair Removal to Sort Array II](https://leetcode.com/problems/minimum-pair-removal-to-sort-array-ii/) | [C++](./C++/minimum-pair-removal-to-sort-array-ii.cpp) [Python](./Python/minimum-pair-removal-to-sort-array-ii.py) | _O(nlogn)_ | _O(n)_ | Hard | | Simulation, Doubly Linked List, Sorted List, BST
3522 | [Calculate Score After Performing Instructions](https://leetcode.com/problems/calculate-score-after-performing-instructions/) | [C++](./C++/calculate-score-after-performing-instructions.cpp) [Python](./Python/calculate-score-after-performing-instructions.py) | _O(n)_ | _O(n)_ | Medium | | Simulation
3561 | [Resulting String After Adjacent Removals](https://leetcode.com/problems/resulting-string-after-adjacent-removals/) | [C++](./C++/resulting-string-after-adjacent-removals.cpp) [Python](./Python/resulting-string-after-adjacent-removals.py) | _O(n)_ | _O(1)_ | Medium | | Simulation, Stack
3597 | [Partition String](https://leetcode.com/problems/partition-string/) | [C++](./C++/partition-string.cpp) [Python](./Python/partition-string.py) | _O(n)_ | _O(t)_ | Medium | | Simulation, Trie
3608 | [Minimum Time for K Connected Components](https://leetcode.com/problems/minimum-time-for-k-connected-components/) | [C++](./C++/minimum-time-for-k-connected-components.cpp) [Python](./Python/minimum-time-for-k-connected-components.py) | _O(n + eloge)_ | _O(n)_ | Medium | | Backward Simulation, Sort, Union Find
3609 | [Minimum Moves to Reach Target in Grid](https://leetcode.com/problems/minimum-moves-to-reach-target-in-grid/) | [C++](./C++/minimum-moves-to-reach-target-in-grid.cpp) [Python](./Python/minimum-moves-to-reach-target-in-grid.py) | _O(logtx + logty)_ | _O(1)_ | Hard | | Backward Simulation
3612 | [Process String with Special Operations I](https://leetcode.com/problems/process-string-with-special-operations-i/) | [C++](./C++/process-string-with-special-operations-i.cpp) [Python](./Python/process-string-with-special-operations-i.py) | _O(r)_ | _O(r)_ | Medium | | Simulation, Deque
3613 | [Minimize Maximum Component Cost](https://leetcode.com/problems/minimize-maximum-component-cost/) | [C++](./C++/minimize-maximum-component-cost.cpp) [Python](./Python/minimize-maximum-component-cost.py) | _O(n + eloge)_ | _O(n)_ | Medium | | Backward Simulation, Sort, Union Find
3614 | [Process String with Special Operations II](https://leetcode.com/problems/process-string-with-special-operations-ii/) | [C++](./C++/process-string-with-special-operations-ii.cpp) [Python](./Python/process-string-with-special-operations-ii.py) | _O(n)_ | _O(1)_ | Hard | | Backward Simulation
3616 | [Number of Student Replacements](https://leetcode.com/problems/number-of-student-replacements/) | [C++](./C++/number-of-student-replacements.cpp) [Python](./Python/number-of-student-replacements.py) | _O(n)_ | _O(1)_ | Medium | 🔒 | Simulation
3639 | [Minimum Time to Activate String](https://leetcode.com/problems/minimum-time-to-activate-string/) | [C++](./C++/minimum-time-to-activate-string.cpp) [Python](./Python/minimum-time-to-activate-string.py) | _O(n)_ | _O(n)_ | Medium | | Backward Simulation, Doubly Linked List
3792 | [Sum of Increasing Product Blocks](https://leetcode.com/problems/sum-of-increasing-product-blocks/) | [C++](./C++/sum-of-increasing-product-blocks.cpp) [Python](./Python/sum-of-increasing-product-blocks.py) | _O(n^2)_ | _O(n^2)_ | Medium | 🔒 | Simulation, Math
3847 | [Find the Score Difference in a Game](https://leetcode.com/problems/find-the-score-difference-in-a-game/) | [C++](./C++/find-the-score-difference-in-a-game.cpp) [Python](./Python/find-the-score-difference-in-a-game.py) | _O(n)_ | _O(1)_ | Medium | | Simulation
3853 | [Merge Close Characters](https://leetcode.com/problems/merge-close-characters/) | [C++](./C++/merge-close-characters.cpp) [Python](./Python/merge-close-characters.py) | _O(n + 26)_ | _O(26)_ | Medium | | Simulation, Freq Table, Two Pointers, Sliding Window
3867 | [Sum of GCD of Formed Pairs](https://leetcode.com/problems/sum-of-gcd-of-formed-pairs/) | [C++](./C++/sum-of-gcd-of-formed-pairs.cpp) [Python](./Python/sum-of-gcd-of-formed-pairs.py) | _O(nlogr)_ | _O(n)_ | Medium | | Simulation, Prefix sum, Sort, Two Pointers
3894 | [Traffic Signal Color](https://leetcode.com/problems/traffic-signal-color/) | [C++](./C++/traffic-signal-color.cpp) [Python](./Python/traffic-signal-color.py) | _O(1)_ | _O(1)_ | Easy | | Simulation
3968 | [Maximum Manhattan Distance After All Moves](https://leetcode.com/problems/maximum-manhattan-distance-after-all-moves/) | [C++](./C++/maximum-manhattan-distance-after-all-moves.cpp) [Python](./Python/maximum-manhattan-distance-after-all-moves.py) | _O(n)_ | _O(1)_ | Medium | | Simulation
4008 | [Minimum Initial Strength to Defeat All Monsters](https://leetcode.com/problems/minimum-initial-strength-to-defeat-all-monsters/) | [C++](./C++/minimum-initial-strength-to-defeat-all-monsters.cpp) [Python](./Python/minimum-initial-strength-to-defeat-all-monsters.py) | _O(n)_ | _O(n)_ | Medium | | Line Sweep, Difference Array, Backward Simulation



    **[⬆️ Back to Top](#algorithms)**




## Constructive Algorithms
|  #  | Title           |  Solution       |  Time           | Space           | Difficulty    | Tag          | Note| 
|-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------|-----|
3139 | [Minimum Cost to Equalize Array](https://leetcode.com/problems/minimum-cost-to-equalize-array/) | [C++](./C++/minimum-cost-to-equalize-array.cpp) [Python](./Python/minimum-cost-to-equalize-array.py) | _O(n)_ | _O(1)_ | Hard | | Constructive Algorithms, Math
3260 | [Find the Largest Palindrome Divisible by K](https://leetcode.com/problems/find-the-largest-palindrome-divisible-by-k/) | [C++](./C++/find-the-largest-palindrome-divisible-by-k.cpp) [Python](./Python/find-the-largest-palindrome-divisible-by-k.py) | _O(n)_ | _O(1)_ | Hard | | String, Constructive Algorithms, Math |
3311 | [Construct 2D Grid Matching Graph Layout](https://leetcode.com/problems/construct-2d-grid-matching-graph-layout/) | [C++](./C++/construct-2d-grid-matching-graph-layout.cpp) [Python](./Python/construct-2d-grid-matching-graph-layout.py) | _O(n)_ | _O(n)_ | Hard | | Graph, Constructive Algorithms, BFS |
3375 | [Minimum Operations to Make Array Values Equal to K](https://leetcode.com/problems/minimum-operations-to-make-array-values-equal-to-k/) | [C++](./C++/minimum-operations-to-make-array-values-equal-to-k.cpp) [Python](./Python/minimum-operations-to-make-array-values-equal-to-k.py) | _O(n)_ | _O(n)_ | Easy | | Hash Table, Constructive Algorithms |
3680 | [Generate Schedule](https://leetcode.com/problems/generate-schedule/) | [C++](./C++/generate-schedule.cpp) [Python](./Python/generate-schedule.py) | _O(n^2)_ | _O(1)_ | Medium | | Constructive Algorithms |
3875 | [Construct Uniform Parity Array I](https://leetcode.com/problems/construct-uniform-parity-array-i/) | [C++](./C++/construct-uniform-parity-array-i.cpp) [Python](./Python/construct-uniform-parity-array-i.py) | _O(1)_ | _O(1)_ | Easy | | Constructive Algorithms |
3876 | [Construct Uniform Parity Array II](https://leetcode.com/problems/construct-uniform-parity-array-ii/) | [C++](./C++/construct-uniform-parity-array-ii.cpp) [Python](./Python/construct-uniform-parity-array-ii.py) | _O(n)_ | _O(1)_ | Medium | | Constructive Algorithms |
3988 | [Create Grid With Exactly K Paths I](https://leetcode.com/problems/create-grid-with-exactly-k-paths-i/) | [C++](./C++/create-grid-with-exactly-k-paths-i.cpp) [Python](./Python/create-grid-with-exactly-k-paths-i.py) | _O(m * n)_ | _O(1)_ | Medium | | Constructive Algorithms |
3990 | [Create Grid With Exactly K Paths II](https://leetcode.com/problems/create-grid-with-exactly-k-paths-ii/) | [C++](./C++/create-grid-with-exactly-k-paths-ii.cpp) [Python](./Python/create-grid-with-exactly-k-paths-ii.py) | _O((logk)^2)_ | _O(1)_ | Hard | 🔒 | Constructive Algorithms |



    **[⬆️ Back to Top](#algorithms)**



## Design
|  #  | Title           |  Solution       |  Time           | Space           | Difficulty    | Tag          | Note| 
|-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------|-----|
3242 | [Design Neighbor Sum Service](https://leetcode.com/problems/design-neighbor-sum-service/) | [C++](./C++/design-neighbor-sum-service.cpp) [Python](./Python/design-neighbor-sum-service.py) | ctor: _O(n^2)_adjacentSum: _O(1)_diagonalSum: _O(1)_ | _O(n^2)_ | Easy | | Hash Table
3369 | [Design an Array Statistics Tracker](https://leetcode.com/problems/design-an-array-statistics-tracker/) | [C++](./C++/design-an-array-statistics-tracker.cpp) [Python](./Python/design-an-array-statistics-tracker.py) | 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](https://leetcode.com/problems/design-a-3d-binary-matrix-with-efficient-layer-tracking/) | [C++](./C++/design-a-3d-binary-matrix-with-efficient-layer-tracking.cpp) [Python](./Python/design-a-3d-binary-matrix-with-efficient-layer-tracking.py) | ctor: _O(1)_setCell: _O(logn)_unsetCell: _O(logn)_largestMatrix: _O(logn)_ | _O(n^3)_ | Medium | 🔒 | Heap, Sorted List
3408 | [Design Task Manager](https://leetcode.com/problems/design-task-manager/) | [C++](./C++/design-task-manager.cpp) [Python](./Python/design-task-manager.py) | ctor: _O(tlogt)_add: _O(logt)_edit: _O(logt)_rmv: _O(logt)_execTop: _O(logt)_ | _O(t)_ | Medium | | Sorted List
3484 | [Design Spreadsheet](https://leetcode.com/problems/design-spreadsheet/) | [C++](./C++/design-spreadsheet.cpp) [Python](./Python/design-spreadsheet.py) | ctor: _O(1)_setCell: _O(1)_resetCell: _O(1)_getValue: _O(1)_ | _O(n)_ | Medium | | Hash Table
3508 | [Implement Router](https://leetcode.com/problems/implement-router/) | [C++](./C++/implement-router.cpp) [Python](./Python/implement-router.py) | 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](https://leetcode.com/problems/design-exam-scores-tracker/) | [C++](./C++/design-exam-scores-tracker.cpp) [Python](./Python/design-exam-scores-tracker.py) | ctor: _O(1)_record: _O(1)_totalScore: _O(logn)_ | _O(n)_ | Medium | | Prefix Sum, Binary Search
3815 | [Design Auction System](https://leetcode.com/problems/design-auction-system/) | [C++](./C++/design-auction-system.cpp) [Python](./Python/design-auction-system.py) | 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](https://leetcode.com/problems/design-order-management-system/) | [C++](./C++/design-order-management-system.cpp) [Python](./Python/design-order-management-system.py) | 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](https://leetcode.com/problems/design-ride-sharing-system/) | [C++](./C++/design-ride-sharing-system.cpp) [Python](./Python/design-ride-sharing-system.py) | ctor: _O(1)_addRider: _O(1)_addDriver: _O(1)_matchDriverWithRider: _O(1)_cancelRider: _O(1)_ | _O(n)_ | Medium | | Ordered Dict
3885 | [Design Event Manager](https://leetcode.com/problems/design-event-manager/) | [C++](./C++/design-event-manager.cpp) [Python](./Python/design-event-manager.py) | ctor: _O(n)_updatePriority: _O(logn)_pollHightest: _O(logn)_ | _O(n)_ | Medium | | Sorted List, BST, Heap, Hash Table



    **[⬆️ Back to Top](#algorithms)**



## JS
|  #  | Title           |  Solution       |  Time           | Space           | Difficulty    | Tag          | Note| 
|-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------|-----|




    **[⬆️ Back to Top](#algorithms)**



## SQL
|  #  | Title           |  Solution       |  Time           | Space           | Difficulty    | Tag          | Note| 
|-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------|-----|
3050 | [Pizza Toppings Cost Analysis](https://leetcode.com/problems/pizza-toppings-cost-analysis/) | [MySQL](./MySQL/pizza-toppings-cost-analysis.sql) | _O(n^3 * logn)_ | _O(n^3)_       | Medium           |🔒||
3051 | [Find Candidates for Data Scientist Position](https://leetcode.com/problems/find-candidates-for-data-scientist-position/) | [MySQL](./MySQL/find-candidates-for-data-scientist-position.sql) | _O(nlogn)_ | _O(n)_       | Easy           |🔒||
3052 | [Maximize Items](https://leetcode.com/problems/maximize-items/) | [MySQL](./MySQL/maximize-items.sql) | _O(n)_ | _O(n)_       | Hard           |🔒||
3053 | [Classifying Triangles by Lengths](https://leetcode.com/problems/classifying-triangles-by-lengths/) | [MySQL](./MySQL/classifying-triangles-by-lengths.sql) | _O(n)_ | _O(n)_       | Easy           |🔒||
3054 | [Binary Tree Nodes](https://leetcode.com/problems/binary-tree-nodes/) | [MySQL](./MySQL/binary-tree-nodes.sql) | _O(nlogn)_ | _O(n)_       | Medium           |🔒||
3055 | [Top Percentile Fraud](https://leetcode.com/problems/top-percentile-fraud/) | [MySQL](./MySQL/top-percentile-fraud.sql) | _O(nlogn)_ | _O(n)_       | Medium           |🔒||
3056 | [Snaps Analysis](https://leetcode.com/snaps-analysis/) | [MySQL](./MySQL/snaps-analysis.sql) | _O(n)_ | _O(n)_       | Medium           |🔒||
3057 | [Employees Project Allocation](https://leetcode.com/problems/employees-project-allocation/) | [MySQL](./MySQL/employees-project-allocation.sql) | _O(nlogn)_ | _O(n)_       | Hard           |🔒||
3058 | [Friends With No Mutual Friends](https://leetcode.com/problems/friends-with-no-mutual-friends/) | [MySQL](./MySQL/friends-with-no-mutual-friends.sql) | _O(n^2 * logn)_ | _O(n^2)_       | Medium           |🔒||
3059 | [Find All Unique Email Domains](https://leetcode.com/problems/find-all-unique-email-domains/) | [MySQL](./MySQL/find-all-unique-email-domains.sql) | _O(nlogn)_ | _O(n)_       | Easy           |🔒||
3060 | [User Activities within Time Bounds](https://leetcode.com/problems/user-activities-within-time-bounds/) | [MySQL](./MySQL/user-activities-within-time-bounds.sql) | _O(nlogn)_ | _O(n)_       | Hard           |🔒||
3061 | [Calculate Trapping Rain Water](https://leetcode.com/problems/calculate-trapping-rain-water/) | [MySQL](./MySQL/calculate-trapping-rain-water.sql) | _O(nlogn)_ | _O(n)_       | Hard           |🔒||
3087 | [Find Trending Hashtags](https://leetcode.com/problems/find-trending-hashtags/) | [MySQL](./MySQL/find-trending-hashtags.sql) | _O(nlogn)_ | _O(n)_       | Medium           |🔒||
3089 | [Find Bursty Behavior](https://leetcode.com/problems/find-bursty-behavior/) | [MySQL](./MySQL/find-bursty-behavior.sql) | _O(nlogn)_ | _O(n)_       | Medium           |🔒| Window Function |
3103 | [Find Trending Hashtags II](https://leetcode.com/problems/find-trending-hashtags-ii/) | [MySQL](./MySQL/find-trending-hashtags-ii.sql) | _O(n * l^2 + (n * l) * log(n * l))_ | _O(n * l^2)_       | Hard           |🔒| Recursive CTE |
3118 | [Friday Purchase III](https://leetcode.com/problems/friday-purchase-iii/) | [MySQL](./MySQL/friday-purchase-iii.sql) | _O(n)_ | _O(n)_       | Medium           |🔒||
3124 | [Find Longest Calls](https://leetcode.com/problems/find-longest-calls/) | [MySQL](./MySQL/find-longest-calls.sql) | _O(nlogn)_ | _O(n)_       | Medium           |🔒| Window Function |
3126 | [Server Utilization Time](https://leetcode.com/problems/server-utilization-time/) | [MySQL](./MySQL/server-utilization-time.sql) | _O(nlogn)_ | _O(n)_       | Medium           || Window Function |
3140 | [Consecutive Available Seats II](https://leetcode.com/problems/consecutive-available-seats-ii/) | [MySQL](./MySQL/consecutive-available-seats-ii.sql) | _O(nlogn)_ | _O(n)_       | Medium           |🔒| Window Function |
3150 | [Invalid Tweets II](https://leetcode.com/problems/invalid-tweets-ii/) | [MySQL](./MySQL/invalid-tweets-ii.sql) | _O(n * l + nlogn)_ | _O(n * l)_       | Easy           |🔒| String |
3156 | [Employee Task Duration and Concurrent Tasks](https://leetcode.com/problems/employee-task-duration-and-concurrent-tasks/) | [MySQL](./MySQL/employee-task-duration-and-concurrent-tasks.sql) | _O(nlogn)_ | _O(n)_       | Hard           |🔒| Line Sweep |
3166 | [Calculate Parking Fees and Duration](https://leetcode.com/problems/calculate-parking-fees-and-duration/) | [MySQL](./MySQL/calculate-parking-fees-and-duration.sql) | _O(nlogn)_ | _O(n)_       | Medium           |🔒|  |
3172 | [Second Day Verification](https://leetcode.com/problems/second-day-verification/) | [MySQL](./MySQL/second-day-verification.sql) | _O(nlogn)_ | _O(n)_       | Easy           |🔒|  |
3182 | [Find Top Scoring Students](https://leetcode.com/problems/find-top-scoring-students/) | [MySQL](./MySQL/find-top-scoring-students.sql) | _O(nlogn)_ | _O(n)_       | Medium           |🔒|  |
3188 | [Find Top Scoring Students II](https://leetcode.com/problems/find-top-scoring-students-ii/) | [MySQL](./MySQL/find-top-scoring-students-ii.sql) | _O(nlogn)_ | _O(n)_       | Hard           |🔒|  |
3198 | [Find Cities in Each State](https://leetcode.com/problems/find-cities-in-each-state/) | [MySQL](./MySQL/find-cities-in-each-state.sql) | _O(nlogn)_ | _O(n)_       | Easy           |🔒|  |
3204 | [Bitwise User Permissions Analysis](https://leetcode.com/problems/bitwise-user-permissions-analysis/) | [MySQL](./MySQL/bitwise-user-permissions-analysis.sql) | _O(n)_ | _O(n)_       | Medium           |🔒|  |
3214 | [Year on Year Growth Rate](https://leetcode.com/problems/year-on-year-growth-rate/) | [MySQL](./MySQL/year-on-year-growth-rate.sql) | _O(nlogn)_ | _O(n)_       | Hard           |🔒|  Window Function |
3220 | [Odd and Even Transactions](https://leetcode.com/problems/odd-and-even-transactions/) | [MySQL](./MySQL/odd-and-even-transactions.sql) | _O(nlogn)_ | _O(n)_       | Medium           ||  |
3230 | [Customer Purchasing Behavior Analysis](https://leetcode.com/problems/customer-purchasing-behavior-analysis/) | [MySQL](./MySQL/customer-purchasing-behavior-analysis.sql) | _O(nlogn)_ | _O(n)_       | Medium           |🔒| Window Function |
3236 | [CEO Subordinate Hierarchy](https://leetcode.com/problems/ceo-subordinate-hierarchy/) | [MySQL](./MySQL/ceo-subordinate-hierarchy.sql) | _O(nlogn)_ | _O(n)_       | Hard           |🔒| Recursive CTE, BFS |
3246 | [Premier League Table Ranking](https://leetcode.com/problems/premier-league-table-ranking/) | [MySQL](./MySQL/premier-league-table-ranking.sql) | _O(nlogn)_ | _O(n)_       | Easy           |🔒| Window Function |
3252 | [Premier League Table Ranking II](https://leetcode.com/problems/premier-league-table-ranking-ii/) | [MySQL](./MySQL/premier-league-table-ranking-ii.sql) | _O(nlogn)_ | _O(n)_       | Medium           |🔒| Window Function |
3262 | [Find Overlapping Shifts](https://leetcode.com/problems/find-overlapping-shifts/) | [MySQL](./MySQL/find-overlapping-shifts.sql) | _O(nlogn)_ | _O(n)_       | Medium           |🔒| Line Sweep |
3268 | [Find Overlapping Shifts II](https://leetcode.com/problems/find-overlapping-shifts-ii/) | [MySQL](./MySQL/find-overlapping-shifts-ii.sql) | _O(n^2)_ | _O(n^2)_       | Hard           |🔒| Line Sweep, Window Function, Combinatorics |
3278 | [Find Candidates for Data Scientist Position II](https://leetcode.com/problems/find-candidates-for-data-scientist-position-ii/) | [MySQL](./MySQL/find-candidates-for-data-scientist-position-ii.sql) | _O(p * s * n + p * nlogn + plogp)_ | _O(p * s * n)_       | Medium           |🔒| Window Function |
3293 | [Calculate Product Final Price](https://leetcode.com/problems/calculate-product-final-price/) | [MySQL](./MySQL/calculate-product-final-price.sql) | _O(nlogn)_ | _O(n)_       | Medium           |🔒|  |
3308 | [Find Top Performing Driver](https://leetcode.com/problems/find-top-performing-driver/) | [MySQL](./MySQL/find-top-performing-driver.sql) | _O(tlogt)_ | _O(t)_       | Medium           |🔒| Window Function |
3322 | [Premier League Table Ranking III](https://leetcode.com/problems/premier-league-table-ranking-iii/) | [MySQL](./MySQL/premier-league-table-ranking-iii.sql) | _O(nlogn)_ | _O(n)_       | Medium           |🔒| Window Function |
3328 | [Find Cities in Each State II](https://leetcode.com/problems/find-cities-in-each-state-ii/) | [MySQL](./MySQL/find-cities-in-each-state-ii.sql) | _O(nlogn)_ | _O(n)_       | Medium           |🔒|  |
3338 | [Second Highest Salary II](https://leetcode.com/problems/second-highest-salary-ii/) | [MySQL](./MySQL/second-highest-salary-ii.sql) | _O(nlogn)_ | _O(n)_       | Medium           |🔒| Window Function |
3358 | [Books with NULL Ratings](https://leetcode.com/problems/books-with-null-ratings/) | [MySQL](./MySQL/books-with-null-ratings.sql) | _O(nlogn)_ | _O(n)_       | Easy           |🔒| |
3368 | [First Letter Capitalization](https://leetcode.com/problems/first-letter-capitalization/) | [MySQL](./MySQL/first-letter-capitalization.sql) | _O(n * l^2 + (n * l) * log(n * l))_ | _O(n * l^2)_       | Hard           |🔒| Recursive CTE |
3374 | [First Letter Capitalization II](https://leetcode.com/problems/first-letter-capitalization-ii/) | [MySQL](./MySQL/first-letter-capitalization-ii.sql) | _O(n * l^2 + (n * l) * log(n * l))_ | _O(n * l^2)_       | Hard           |🔒| Recursive CTE |
3384 | [Team Dominance by Pass Success](https://leetcode.com/problems/team-dominance-by-pass-success/) | [MySQL](./MySQL/team-dominance-by-pass-success.sql) | _O(plogp + t)_ | _O(p + t)_       | Hard           |🔒| |
3390 | [Longest Team Pass Streak](https://leetcode.com/problems/longest-team-pass-streak/) | [MySQL](./MySQL/longest-team-pass-streak.sql) | _O(plogp + t)_ | _O(p + t)_       | Hard           |🔒| Recursive CTE, Window Function |
3401 | [Find Circular Gift Exchange Chains](https://leetcode.com/problems/find-circular-gift-exchange-chains/) | [MySQL](./MySQL/find-circular-gift-exchange-chains.sql) | _O(n^2)_ | _O(n^2)_       | Hard           |🔒| Recursive CTE, Window Function |
3415 | [Find Products with Three Consecutive Digits](https://leetcode.com/problems/find-products-with-three-consecutive-digits/) | [MySQL](./MySQL/find-products-with-three-consecutive-digits.sql) | _O(nlogn)_ | _O(n)_       | Easy           |🔒| Regular Expression |
3421 | [Find Students Who Improved](https://leetcode.com/problems/find-students-who-improved/) | [MySQL](./MySQL/find-students-who-improved.sql) | _O(nlogn)_ | _O(n)_       | Medium           |🔒| Window Function |
3436 | [Find Valid Emails](https://leetcode.com/problems/find-valid-emails/) | [MySQL](./MySQL/find-valid-emails.sql) | _O(n)_ | _O(n)_       | Easy           || Regular Expression |
3451 | [Find Invalid IP Addresses](https://leetcode.com/problems/find-invalid-ip-addresses/) | [MySQL](./MySQL/find-invalid-ip-addresses.sql) | _O(nlogn)_ | _O(n)_       | Hard           || Regular Expression |
3465 | [Find Products with Valid Serial Numbers](https://leetcode.com/problems/find-products-with-valid-serial-numbers/) | [MySQL](./MySQL/find-products-with-valid-serial-numbers.sql) | _O(nlogn)_ | _O(n)_       | Easy           || Regular Expression |
3475 | [DNA Pattern Recognition](https://leetcode.com/problems/dna-pattern-recognition/) | [MySQL](./MySQL/dna-pattern-recognition.sql) | _O(nlogn)_ | _O(n)_       | Medium           || Regular Expression |
3482 | [Analyze Organization Hierarchy](https://leetcode.com/problems/analyze-organization-hierarchy/) | [MySQL](./MySQL/analyze-organization-hierarchy.sql) | _O(n^2)_ | _O(n^2)_       | Hard           || Recursive CTE, BFS |
3497  | [Analyze Subscription Conversion](https://leetcode.com/problems/analyze-subscription-conversion/) | [MySQL](./MySQL/analyze-subscription-conversion.sql) | _O(nlogn)_ | _O(n)_       | Medium           |||
3521  | [Find Product Recommendation Pairs](https://leetcode.com/problems/find-product-recommendation-pairs/) | [MySQL](./MySQL/find-product-recommendation-pairs.sql) | _O(n^2 * logn)_ | _O(n^2)_       | Medium           |||
3554  | [Find Category Recommendation Pairs](https://leetcode.com/problems/find-category-recommendation-pairs/) | [MySQL](./MySQL/find-category-recommendation-pairs.sql) | _O(n^2 * logn)_ | _O(n^2)_       | Hard           |||
3564  | [Seasonal Sales Analysis](https://leetcode.com/problems/seasonal-sales-analysis/) | [MySQL](./MySQL/seasonal-sales-analysis.sql) | _O(nlogn)_ | _O(n)_       | Medium           || Window Function|
3570  | [Find Books with No Available Copies](https://leetcode.com/problems/find-books-with-no-available-copies/) | [MySQL](./MySQL/find-books-with-no-available-copies.sql) | _O(nlogn)_ | _O(n)_       | Easy           |||
3580  | [Find Consistently Improving Employees](https://leetcode.com/problems/find-consistently-improving-employees/) | [MySQL](./MySQL/find-consistently-improving-employees.sql) | _O(nlogn)_ | _O(n)_       | Medium           || Window Function |
3586  | [Find COVID Recovery Patients](https://leetcode.com/problems/find-covid-recovery-patients/) | [MySQL](./MySQL/find-covid-recovery-patients.sql) | _O(n^2)_ | _O(n^2)_       | Medium           || |
3601  | [Find Drivers with Improved Fuel Efficiency](https://leetcode.com/problems/find-drivers-with-improved-fuel-efficiency/) | [MySQL](./MySQL/find-drivers-with-improved-fuel-efficiency.sql) | _O(nlogn)_ | _O(n)_       | Medium           || |
3611  | [Find Overbooked Employees](https://leetcode.com/problems/find-overbooked-employees/) | [MySQL](./MySQL/find-overbooked-employees.sql) | _O(m + nlogn)_ | _O(m + n)_       | Medium           || |
3617  | [Find Students with Study Spiral Pattern](https://leetcode.com/problems/find-students-with-study-spiral-pattern/) | [MySQL](./MySQL/find-students-with-study-spiral-pattern.sql) | _O(nlogn)_ | _O(n)_       | Hard           || Window Function |
3626  | [Find Stores with Inventory Imbalance](https://leetcode.com/problems/find-stores-with-inventory-imbalance/) | [MySQL](./MySQL/find-stores-with-inventory-imbalance.sql) | _O(n^2 * logn)_ | _O(n^2)_       | Medium           || |
3642  | [Find Books with Polarized Opinions](https://leetcode.com/problems/find-books-with-polarized-opinions/) | [MySQL](./MySQL/find-books-with-polarized-opinions.sql) | _O(r + nlogn)_ | _O(r + n)_       | Easy           || |
3657  | [Find Loyal Customers](https://leetcode.com/problems/find-loyal-customers/) | [MySQL](./MySQL/find-loyal-customers.sql) | _O(nlogn)_ | _O(n)_       | Medium           || |
3673  | [Find Zombie Sessions](https://leetcode.com/problems/find-zombie-sessions/) | [MySQL](./MySQL/find-zombie-sessions.sql) | _O(nlogn)_ | _O(n)_       | Hard           || |
3705  | [Find Golden Hour Customers](https://leetcode.com/problems/find-golden-hour-customers/) | [MySQL](./MySQL/find-golden-hour-customers.sql) | _O(nlogn)_ | _O(n)_       | Medium           || |
3716  | [Find Churn Risk Customers](https://leetcode.com/problems/find-churn-risk-customers/) | [MySQL](./MySQL/find-churn-risk-customers.sql) | _O(nlogn)_ | _O(n)_       | Medium           || Window Function |
3764  | [Most Common Course Pairs](https://leetcode.com/problems/most-common-course-pairs/) | [MySQL](./MySQL/most-common-course-pairs.sql) | _O(nlogn)_ | _O(n)_       | Hard           || Window Function |
3793  | [Find Users with High Token Usage](https://leetcode.com/problems/find-users-with-high-token-usage/) | [MySQL](./MySQL/find-users-with-high-token-usage.sql) | _O(nlogn)_ | _O(n)_       | Easy           || |
3808  | [Find Emotionally Consistent Users](https://leetcode.com/problems/find-emotionally-consistent-users/) | [MySQL](./MySQL/find-emotionally-consistent-users.sql) | _O(nlogn)_ | _O(n)_       | Medium           || Window Function |
3832  | [Find Users with Persistent Behavior Patterns](https://leetcode.com/problems/find-users-with-persistent-behavior-patterns/) | [MySQL](./MySQL/find-users-with-persistent-behavior-patterns.sql) | _O(nlogn)_ | _O(n)_       | Hard           || Window Function |



    **[⬆️ Back to Top](#algorithms)**



## PD
|  #  | Title           |  Solution       |  Time           | Space           | Difficulty    | Tag          | Note| 
|-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------|-----|



    **[⬆️ Back to Top](#algorithms)**