kamyu104/LeetCode-Solutions

🏋️ Python / Modern C++ Solutions of All 4073 LeetCode Problems (Weekly Update)

C++

5,949

20,998 commits

updated Oct 12, 2026

See the code

README

LeetCode

Language  License  Update  Progress  SayThanks  Visitors

  • 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, GoogleKickStart, GoogleCodeJamIO repositories.
  • For more challenging problem solutions, you can also see my GoogleCodeJam, MetaHackerCup repositories.
  • Hope you enjoy the journey of learning data structures and algorithms.
  • Notes: "🔒" means your subscription of LeetCode premium membership is required for reading the question.

Solutions

Algorithms

JavaScript

Database

Pandas

Reference

Bit Manipulation

#TitleSolutionTimeSpaceDifficultyTagNote
3064Guess the Number Using Bitwise Questions IC++ PythonO(logn)O(1)Medium🔒Bit Manipulation
3094Guess the Number Using Bitwise Questions IIC++ PythonO(logr)O(1)Medium🔒Bit Manipulation
3125Maximum Number That Makes Result of Bitwise AND ZeroC++ PythonO(1)O(1)Medium🔒Bit Manipulation
3133Minimum Array EndC++ PythonO(logn)O(1)MediumBit Manipulation
3199Count Triplets with Even XOR Set Bits IC++ PythonO(nlogr)O(1)Easy🔒Brute Force, Bit Manipulation, Parity
3215Count Triplets with Even XOR Set Bits IIC++ PythonO(nlogr)O(1)Medium🔒Bit Manipulation, Parity
3226Number of Bit Changes to Make Two Integers EqualC++ PythonO(logn)O(1)EasyBit Manipulation
3289The Two Sneaky Numbers of DigitvilleC++ PythonO(n)O(1)EasyBit Manipulation
3304Find the K-th Character in String Game IC++ PythonO(n)O(1)EasyBitmasks
3307Find the K-th Character in String Game IIC++ PythonO(1)O(1)HardBitmasks
3314Construct the Minimum Bitwise Array IC++ PythonO(n)O(1)EasyBit Manipulation
3315Construct the Minimum Bitwise Array IIC++ PythonO(n)O(1)MediumBit Manipulation
3344Maximum Sized ArrayC++ Pythonprecompute: O(max_s^(1/5) * log(max_s))
runtime: O(log(max_s))
O(max_s^(1/5))Medium🔒Precompute, Bitmasks, Combinatorics, Binary Search
3370Smallest Number With All Set BitsC++ PythonO(1)O(1)EasyBit Manipulation
3566Partition Array into Two Equal Product SubsetsC++ PythonO(n * 2^n)O(1)MediumBitmasks
3632Subarrays with XOR at Least KC++ PythonO(nlogr)O(t)Hard🔒Bitmasks, Prefix Sum, Trie
3646Next Special Palindrome NumberC++ Pythonprecompute: O(9 * 2^9 + 16 * p + plogp)
runtime: O(logp)
O(p)HardPrecompute, Bitmasks, Sort, Binary Search
3702Longest Subsequence With Non-Zero Bitwise XORC++ PythonO(n)O(1)MediumBitmasks
3750Minimum Number of Flips to Reverse Binary StringC++ PythonO(logn)O(1)EasyBitmasks
3766Minimum Operations to Make Binary PalindromeC++ Pythonprecompute: O(sqrt(r) * logr)
runtime: O(r)
O(r)MediumPrecompute, Bitmasks, Two Pointers
3769Sort Integers by Binary ReflectionC++ PythonO(nlogr + nlogn)O(n)EasySort, Bitmasks
3782Last Remaining Integer After Alternating Deletion OperationsC++ PythonO(1)O(1)HardBitmasks, Simulation
3827Count Monobit IntegersC++ PythonO(logn)O(1)EasyBitmasks
3950Exactly One Consecutive Set Bits PairC++ PythonO(1)O(1)EasyBit Manipulation
4005Minimum Operations to Make Array Equal IIIC++ PythonO(nlogr)O(n)Hard🔒Freq Table, Bit Manipulation


Array

#TitleSolutionTimeSpaceDifficultyTagNote
3009Maximum Number of Intersections on the ChartC++ PythonO(nlogn)O(n)Hard🔒Sort, Line Sweep, Coordinate Compression
3010Divide an Array Into Subarrays With Minimum Cost IC++ PythonO(n)O(1)EasyArray, Quick Select
3015Count the Number of Houses at a Certain Distance IC++ PythonO(n)O(n)MediumMath, Prefix Sum, Difference Array
3017Count the Number of Houses at a Certain Distance IIC++ PythonO(n)O(1)HardMath, Prefix Sum, Difference Array
3026Maximum Good Subarray SumC++ PythonO(n)O(n)MediumPrefix Sum
3028Ant on the BoundaryC++ PythonO(n)O(1)EasyPrefix Sum
3030Find the Grid of Region AverageC++ PythonO(m * n)O(m * n)MediumArray
3033Modify the MatrixC++ PythonO(m * n)O(1)EasyArray
3038Maximum Number of Operations With the Same Score IC++ PythonO(n)O(1)EasyArray
3065Minimum Operations to Exceed Threshold Value IC++ PythonO(n)O(1)EasyArray
3069Distribute Elements Into Two Arrays IC++ PythonO(n)O(n)EasyArray
3070Count Submatrices with Top-Left Element and Sum Less Than kC++ PythonO(n * m)O(1)MediumArray, Prefix Sum
3071Minimum Operations to Write the Letter Y on a GridC++ PythonO(n^2)O(1)MediumArray
3079Find the Sum of Encrypted IntegersC++ PythonO(nlogr)O(1)EasyArray
3096Minimum Levels to Gain More PointsC++ PythonO(n)O(n)MediumPrefix Sum
3105Longest Strictly Increasing or Strictly Decreasing SubarrayC++ PythonO(n)O(1)EasyArray
3127Make a Square with the Same ColorC++ PythonO((n - w + 1)^2 * w^2)O(1)EasyArray
3131Find the Integer Added to Array IC++ PythonO(n)O(1)EasyArray
3142Check if Grid Satisfies ConditionsC++ PythonO(m * n)O(1)EasyArray
3147Taking Maximum Energy From the Mystic DungeonC++ PythonO(n)O(1)MediumArray
3151Special Array IC++ PythonO(n)O(1)EasyArray
3152Special Array IIC++ PythonO(n + q)O(n)MediumPrefix Sum
3153Sum of Digit Differences of All PairsC++ PythonO(nlogr)O(10 * logr)MediumPrefix Sum
3159Find Occurrences of an Element in an ArrayC++ PythonO(n + q)O(n)MediumArray
3173Bitwise OR of Adjacent ElementsC++ PythonO(n)O(1)Easy🔒Array
3187Peaks in ArrayC++ PythonO(n + qlogn)O(n)HardBIT, Fenwick Tree
3195Find the Minimum Area to Cover All Ones IC++ PythonO(n * m)O(1)MediumArray
3224Minimum Array Changes to Make Differences EqualC++ PythonO(n + k)O(k)MediumPrefix Sum, Difference Array
3279Maximum Total Area Occupied by PistonsC++ PythonO(h)O(h)Hard🔒Line Sweep, Difference Array
3285Find Indices of Stable MountainsC++ PythonO(n)O(1)EasyArray
3300Minimum Element After Replacement With Digit SumC++ PythonO(nlogr)O(1)EasyArray
3330Find the Original Typed String IC++ PythonO(n)O(1)EasyArray
3334Find the Maximum Factor Score of ArrayC++ PythonO(nlogr)O(n)MediumPrefix Sum
3349Adjacent Increasing Subarrays Detection IC++ PythonO(n)O(1)EasyArray
3350Adjacent Increasing Subarrays Detection IIC++ PythonO(n)O(1)MediumArray
3353Minimum Total OperationsC++ PythonO(n)O(1)Easy🔒Array
3354Make Array Elements Equal to ZeroC++ PythonO(n)O(n)EasyCodeChef Starters 146 - Bouncing BallPrefix Sum
3355Zero Array Transformation IC++ PythonO(n + q)O(n)MediumLine Sweep
3361Shift Distance Between Two StringsC++ PythonO(n + 26)O(26)MediumPrefix Sum
3379Transformed ArrayC++ PythonO(n)O(1)EasyArray
3380Maximum Area Rectangle With Point Constraints IC++ PythonO(nlogn)O(n)MediumSort, Brute Force, BIT, Fenwick Tree, Hash Table
3382Maximum Area Rectangle With Point Constraints IIC++ PythonO(nlogn)O(n)HardSort, BIT, Fenwick Tree, Hash Table
3386Button with Longest Push TimeC++ PythonO(n)O(1)EasyArray
3392Count Subarrays of Length Three With a ConditionC++ PythonO(n)O(1)EasyArray
3400Maximum Number of Matching Indices After Right ShiftsC++ PythonO(n^2)O(1)Medium🔒Brute Force
3417Zigzag Grid Traversal With SkipC++ PythonO(n * m)O(1)EasyArray
3423Maximum Difference Between Adjacent Elements in a Circular ArrayC++ PythonO(n)O(1)EasyArray
3427Sum of Variable Length SubarraysC++ PythonO(n)O(n)EasyDifference Array
3432Count Partitions with Even Sum DifferenceC++ PythonO(n)O(1)EasyPrefix Sum
3440Reschedule Meetings for Maximum Free Time IIC++ PythonO(n)O(1)MediumArray
3446Sort Matrix by DiagonalsC++ PythonO(n^2 * logn)O(n^2)MediumArray, Sort
3452Sum of Good NumbersC++ PythonO(n)O(1)EasyArray
3467Transform Array by ParityC++ PythonO(n)O(1)EasyArray
3502Minimum Cost to Reach Every PositionC++ PythonO(n)O(1)EasyPrefix Sum
3514Number of Unique XOR Triplets IIC++ PythonO(nlogn)O(n)MediumFast Walsh–Hadamard Transform, FWHT, Fast Subset Transform, FST, Hash Table
3531Count Covered BuildingsC++ PythonO(n)O(n)MediumArray
3537Fill a Special GridC++ PythonO(4^n)O(1)MediumDivide and Conquer, Array
3540Minimum Time to Visit All HousesC++ PythonO(n + q)O(n)Medium🔒Prefix Sum
3546Equal Sum Grid Partition IC++ PythonO(m * n)O(1)MediumArray
3548Equal Sum Grid Partition IIC++ PythonO(m * n)O(m * n)HardArray, Hash Table
3549Multiply Two PolynomialsC++ PythonO((n + m) * log(n + m))O(n + m)Hard🔒Fast Fourier Transform, FFT
3550Smallest Index With Digit Sum Equal to IndexC++ PythonO(nlogr)O(1)EasyArray
3569Maximize Count of Distinct Primes After SplitC++ PythonO(r + nlogn + qlogn)O(r + n)MediumNumber Theory, BST, Sorted List, Segment Tree
3637Trionic Array IC++ PythonO(n)O(1)EasyArray
3643Flip Square Submatrix VerticallyC++ PythonO(k^2)O(1)EasyArray
3653XOR After Range Multiplication Queries IC++ PythonO(qlogm + (q + n) * sqrt(n))O(n * sqrt(n))MediumSqrt Decomposition, Difference Array, Fast Exponentiation, Simulation
3655XOR After Range Multiplication Queries IIC++ PythonO(qlogm + (q + n) * sqrt(n))O(n * sqrt(n))HardSqrt Decomposition, Difference Array, Fast Exponentiation
3674Minimum Operations to Equalize ArrayC++ PythonO(n)O(1)EasyArray
3683Earliest Time to Finish One TaskC++ PythonO(n)O(1)EasyArray
3687Library Late Fee CalculatorC++ PythonO(n)O(1)Easy🔒Array
3688Bitwise OR of Even Numbers in an ArrayC++ PythonO(n)O(1)EasyArray
3696Maximum Distance Between Unequal Words in Array IC++ PythonO(n * l)O(1)Easy🔒Array
3700Number of ZigZag Arrays IIC++ PythonO((r - l)^3 * logn)O((r - l)^2)HardMatrix Exponentiation
3701Compute Alternating SumC++ PythonO(n)O(1)EasyArray
3706Maximum Distance Between Unequal Words in Array IIC++ PythonO(n * l)O(1)Medium🔒Array
3707Equal Score SubstringsC++ PythonO(n)O(1)EasyArray, Prefix Sum
3708Longest Fibonacci SubarrayC++ PythonO(n)O(1)MediumArray
3719Longest Balanced Subarray IC++ PythonO(nlogn)O(n)MediumBrute Force, Segment Tree, Binary Search, Prefix Sum
3721Longest Balanced Subarray IIC++ PythonO(nlogn)O(n)HardSegment Tree, Binary Search, Prefix Sum
3736Minimum Moves to Equal Array Elements IIIC++ PythonO(n)O(1)EasyArray
3737Count Subarrays With Majority Element IC++ PythonO(n)O(n)MediumFreq Table, Prefix Sum
3738Longest Non-Decreasing Subarray After Replacing at Most One ElementC++ PythonO(n)O(n)MediumArray, Prefix Sum
3739Count Subarrays With Majority Element IIC++ PythonO(n)O(n)HardFreq Table, Prefix Sum
3751Total Waviness of Numbers in Range IC++ PythonO(nlogn)O(logn)MediumBrute Force
3756Concatenate Non-Zero Digits and Multiply by Sum IIC++ PythonO(n)O(n)MediumPrefix Sum
3762Minimum Operations to Equalize SubarraysC++ PythonO((n + q) * logn)O(nlogn)HardPrefix Sum, Coordinate Compression, Persistent Segment Tree, Binary Search
3774Absolute Difference Between Maximum and Minimum K ElementsC++ PythonO(n)O(1)EasySort, Quick Select
3788Maximum Score of a SplitC++ PythonO(n)O(1)MediumPrefix Sum
3809Best Reachable TowerC++ PythonO(n)O(1)MediumArray
3814Maximum Capacity Within BudgetC++ PythonO(n + b)O(b)MediumHash Table, Prefix Sum, Sort, Mono Stack, Binary Search
3818Minimum Prefix Removal to Make Array Strictly IncreasingC++ PythonO(n)O(1)MediumArray
3819Rotate Non Negative ElementsC++ PythonO(n)O(n)MediumArray
3833Count Dominant IndicesC++ PythonO(n)O(1)EasyArray
3861Minimum Capacity BoxC++ PythonO(n)O(1)EasyArray
3862Find the Smallest Balanced IndexC++ PythonO(n)O(1)MediumPrefix Sum
3865Reverse K SubarraysC++ PythonO(n)O(1)Medium🔒Array
3880Minimum Absolute Difference Between Two ValuesC++ PythonO(n)O(1)EasyArray
3886Sum of Sortable IntegersC++ PythonO(nlog(logn))O(n)HardPrefix Sum, Number Theory
3898Find the Degree of Each VertexC++ PythonO(n * m)O(1)EasyArray
3903Smallest Stable Index IC++ PythonO(n)O(n)EasyPrefix Sum
3904Smallest Stable Index IIC++ PythonO(n)O(n)MediumPrefix Sum
3907Count Smaller Elements With Opposite ParityC++ PythonO(nlogn)O(n)Medium🔒Sort, Coordinate Compression, BIT, Fenwick Tree
3909Compare Sums of Bitonic PartsC++ PythonO(n)O(1)MediumArray
3912Valid Elements in an ArrayC++ PythonO(n)O(n)MediumPrefix Sum
3915Maximum Sum of Alternating Subsequence With Distance at Least KC++ PythonO(nlogn)O(n)HardSort, Coordinate Compression, BIT, Fenwick Tree, Sliding Window, DP
3918Sum of Primes Between Number and Its ReverseC++ Pythonprecompute: O(r)
runtime: O(1)
O(r)MediumNumber Theory, Linear Sieve of Eratosthenes, Prefix Sum
3925Concatenate Array With ReverseC++ PythonO(n)O(1)EasyArray
3933Largest Local Values in a Matrix IIC++ PythonO(n * m * logn * logm)O(n * m * logn * logm)MediumRMQ, 2D Sparse Table
3936Minimum Swaps to Move Zeros to EndC++ PythonO(n)O(1)EasyArray
3938Maximum Path Intersection Sum in a GridC++ PythonO(n * m)O(1)MediumArray, Kadane's Algorithm
3940Limit Occurrences in Sorted ArrayC++ PythonO(n)O(1)EasyArray, Inplace
3942Minimum Operations to Sort a PermutationC++ PythonO(n)O(1)MediumArray
3943Number of Pairs After IncrementC++ PythonO(n + m + q * sqrt(m * n))O(n + m)HardFreq Table, Sqrt Decomposition
3951Minimum Energy to Maintain BrightnessC++ PythonO(nlogn)O(1)MediumSort, Line Sweep
3951Minimum Energy to Maintain BrightnessC++ PythonO(nlogn)O(1)MediumSort, Line Sweep
3963Create Grid With Exactly One PathC++ PythonO(m * n)O(1)EasyArray
3978Unique Middle ElementC++ PythonO(n)O(1)EasyArray
3979Maximum Valid Pair SumC++ PythonO(n)O(n)MediumPrefix Sum
3982Sum of Integers with Maximum Digit RangeC++ PythonO(nlogr)O(1)EasyArray
3985Palindromic Subarray SumC++ PythonO(n)O(n)HardPrefix Sum, Manacher's Algorithm
3998Transform Binary String Using Subsequence SortC++ PythonO(n * m)O(n)HardPrefix Sum
4006Count Valid PrefixesC++ PythonO(n)O(1)EasyPrefix Sum
4010Maximize Pair Strength Using GCDC++ PythonO(n^2 * logr)O(1)EasyBrute Force, Sort, Pruning
4011Count Subarrays With Even Odd Ratio IC++ PythonO(nlogn)O(n)MediumPrefix Sum, Sort, Coordinate Compression, BIT, Fenwick Tree, Brute Force
4012Count of Unfinished Tasks After Each ShiftC++ PythonO(n + mlogn)O(n)MediumPrefix Sum, Binary Search
4013Count Subarrays With Even Odd Ratio IIC++ PythonO(nlogn)O(n)HardPrefix Sum, Sort, Coordinate Compression, BIT, Fenwick Tree
4017Peaks in Array IIC++ PythonO(nlogn + qlogn)O(n)HardBIT, Fenwick Tree
4020Elevator Requests IC++ PythonO(m)O(1)EasyArray
4021Minimum Operations to Make a Rotated Palindrome IC++ PythonO(nlogn)O(n)MediumBrute Force, NTT
4024Nearest Available DroneC++ PythonO(n)O(1)EasyArray
4028Minimum Operations to Make a Rotated Palindrome IIC++ PythonO(nlogn)O(n)Hard🔒NTT
4051Count Subarrays with Distant SumsC++ PythonO(nlogn)O(n)HardPrefix Sum, Sorted List, Ordered Set, BIT, Fenwick Tree
4052Cyclically Shift Rows and ColumnsC++ PythonO(n^2)O(1)EasyArray, Inplace
4056Number of Intersecting Interval Pairs IC++ PythonO(nlogn)O(n)EasyBrute Force, Sort, Line Sweep
4057Number of Intersecting Interval Pairs IIC++ PythonO(nlogn)O(n)MediumSort, Line Sweep
4058Maximum Pulse Value After One Subarray RotationC++ PythonO(n)O(1)MediumPrefix Sum, Hash Table
4062Transform Array Using Pair OperationsC++ PythonO(n)O(1)MediumArray
4063Longest Subarray Divisible by K with At Most One Negation IC++ PythonO(n + k^2)O(k)MediumPrefix Sum, Hash Table, Brute Force
4064Longest Subarray Divisible by K with At Most One Negation IIC++ PythonO(n + k^2)O(k)HardPrefix Sum, Hash Table
4073Count Good StringsC++ PythonO(logr)O(1)HardMatrix Fast Exponentiation


String

#TitleSolutionTimeSpaceDifficultyTagNote
3019Number of Changing KeysC++ PythonO(n)O(1)EasyString
3023Find Pattern in Infinite Stream IC++ PythonO(p + n)O(p)Medium🔒String, KMP Algorithm
3029Minimum Time to Revert Word to Initial State IC++ PythonO(n)O(n)MediumString, Z-Function, Brute Force
3031Minimum Time to Revert Word to Initial State IIC++ PythonO(n)O(n)HardString, Z-Function
3034Number of Subarrays That Match a Pattern IC++ PythonO(n)O(m)MediumBrute Force, String, KMP Algorithm
3036Number of Subarrays That Match a Pattern IIC++ PythonO(n)O(m)HardString, KMP Algorithm
3037Find Pattern in Infinite Stream IIC++ PythonO(p + n)O(p)Hard🔒String, KMP Algorithm
3042Count Prefix and Suffix Pairs IC++ PythonO(n * l)O(t)EasyTrie, Brute Force
3043Find the Length of the Longest Common PrefixC++ PythonO((n + m) * l)O(t)MediumTrie, Hash Table
3045Count Prefix and Suffix Pairs IIC++ PythonO(n * l)O(t)HardTrie
3076Shortest Uncommon Substring in an ArrayC++ PythonO(n * l^2)O(t)MediumTrie
3093Longest Common Suffix QueriesC++ PythonO((n + q) * l)O(t)HardTrie
3110Score of a StringC++ PythonO(n)O(1)EasyString
3136Valid WordC++ PythonO(n)O(1)EasyString
3163String Compression IIIC++ PythonO(n)O(1)MediumString
3210Find the Encrypted StringC++ PythonO(n)O(1)MediumString
3271Hash Divided StringC++ PythonO(n)O(1)MediumString
3280Convert Date to BinaryC++ PythonO(1)O(1)EasyString
3303Find the Occurrence of First Almost Equal SubstringC++ PythonO(n + m)O(n + m)HardZ-Function
3324Find the Sequence of Strings Appeared on the ScreenC++ PythonO(n^2)O(1)MediumString
3340Check Balanced StringC++ PythonO(n)O(1)EasyString
3407Substring Matching PatternC++ PythonO(n + m)O(m)EasyString, KMP Algorithm
3455Shortest Matching SubstringC++ PythonO(n + m)O(n + m)HardString, KMP Algorithm, Two Pointers
3456Find Special Substring of Length KC++ PythonO(n)O(1)EasyString
3491Phone Number PrefixC++ PythonO(l * nlogn)O(1)Easy🔒Trie, Sort
3498Reverse Degree of a StringC++ PythonO(n)O(1)EasyString
3529Count Cells in Overlapping Horizontal and Vertical SubstringsC++ PythonO(n * m)O(n * m)MediumZ-Function
3571Find the Shortest Superstring IIC++ PythonO(n + m)O(n + m)Easy🔒KMP Algorithm
3582Generate Tag for Video CaptionC++ PythonO(n)O(1)EasyString
3598Longest Common Prefix Between Adjacent Strings After RemovalsC++ PythonO(n * l)O(n)MediumLCP, Prefix Sum
3606Coupon Code ValidatorC++ PythonO(l * nlogn)O(n * l)EasyHash Table, Sort
3744Find Kth Character in Expanded StringC++ PythonO(n)O(1)Medium🔒String
3746Minimum String Length After Balanced RemovalsC++ PythonO(n)O(1)MediumString
3748Count Stable SubarraysC++ PythonO(n + q)O(n)HardPrefix Sum
3758Convert Number Words to DigitsC++ PythonO(n)O(1)Medium🔒String
3775Reverse Words With Same Vowel CountC++ PythonO(n)O(1)MediumString, Inplace
3777Minimum Deletions to Make Alternating SubstringC++ PythonO((n + q) * logn)O(n)HardBIT, Fenwick Tree
3794Reverse String PrefixC++ PythonO(n)O(1)EasyString
3813Vowel-Consonant ScoreC++ PythonO(n)O(1)EasyString
3823Reverse Letters Then Special Characters in a StringC++ PythonO(n)O(1)EasyString
3838Weighted Word MappingC++ PythonO(n * l)O(1)EasyString
3856Trim Trailing VowelsC++ PythonO(n)O(1)EasyString
3860Unique Email GroupsC++ PythonO(n * l)O(n * l)Medium🔒String, Hash Table
3884First Matching Character From Both EndsC++ PythonO(n)O(1)MediumString
3931Check Adjacent Digit DifferencesC++ PythonO(n)O(1)EasyString
3941Password StrengthC++ PythonO(n)O(1)MediumString, Hash Table
3986Number of Elapsed Seconds Between Two TimesC++ PythonO(1)O(1)EasyString
3999Minimum Number of String Groups Through TransformationsC++ PythonO(n * l)O(n * l)HardHash Table, String
4030Check ASCII PalindromicC++ PythonO(n)O(1)EasyString, Bitmasks
4043Count Rotations With Exactly K Equal Adjacent PairsC++ PythonO(n)O(1)EasyString
4070Minimum Rotations to Dial a Number IC++ PythonO(n)O(1)EasyString
4071Minimum Rotations to Dial a Number IIC++ PythonO(n)O(1)MediumString


Linked List

#TitleSolutionTimeSpaceDifficultyTagNote
3062Winner of the Linked List GameC++ PythonO(n)O(1)Easy🔒Linked List
3063Linked List FrequencyC++ PythonO(n)O(1)Medium🔒Linked List
3217Delete Nodes From Linked List Present in ArrayC++ PythonO(n)O(m)MediumHash Table, Linked List
3263Convert Doubly Linked List to Array IC++ PythonO(n)O(1)Easy🔒Linked List
3294Convert Doubly Linked List to Array IIC++ PythonO(n)O(1)Medium🔒Linked List


Stack

#TitleSolutionTimeSpaceDifficultyTagNote
3113Find the Number of Subarrays Where Boundary Elements Are MaximumC++ PythonO(n)O(n)HardMono Stack, Combinatorics
3174Clear DigitsC++ PythonO(n)O(1)EasyStack, Two Pointers
3676Count Bowl SubarraysC++ PythonO(n)O(n)MediumMono Stack
3703Remove K-Balanced SubstringsC++ PythonO(n)O(n)MediumStack
3749Evaluate Valid ExpressionsC++ PythonO(n)O(n)Hard🔒Stack
3834Merge Adjacent Equal ElementsC++ PythonO(n)O(1)MediumStack, Simulation
3878Count Good SubarraysC++ PythonO(n)O(n)HardCombinatorics, Mono Stack
4054Count Shadow Pairs IC++ PythonO(n)O(n)MediumFreq Table, Mono Stack
4055Count Shadow Pairs IIC++ PythonO(nlogn)O(n)HardCoordinate Compression, Merge Sort, Mono Stack


Queue

#TitleSolutionTimeSpaceDifficultyTagNote


Binary Heap

#TitleSolutionTimeSpaceDifficultyTagNote
3066Minimum Operations to Exceed Threshold Value IIC++ PythonO(nlogn)O(n)MediumSimulation, Heap
3080Mark Elements on Array by Performing QueriesC++ PythonO(q + nlogn)O(n)MediumHash Table, Heap
3092Most Frequent IDsC++ PythonO(nlogn)O(n)MediumHeap, BST, Sorted List
3256Maximum Value Sum by Placing Three Rooks IC++ PythonO(m * n)O(m + n)HardHeap, Brute Force
3257Maximum Value Sum by Placing Three Rooks IIC++ PythonO(m * n)O(m + n)HardHeap, Brute Force
3275K-th Nearest Obstacle QueriesC++ PythonO(qlogk)O(k)MediumHeap
3684Maximize Sum of At Most K Distinct ElementsC++ PythonO(nlogk)O(k)EasyHeap, Sort
3691Maximum Total Subarray Value IIC++ PythonO((n + k) * logn)O(n)HardHeap, Sort, Two Pointers, RMQ, Sparse Table, Segment Tree
3781Maximum Score After Binary SwapsC++ PythonO(nlogn)O(n)MediumHeap
3962Maximum Subarray Sum After at Most K SwapsC++ PythonO(n^2 * logk)O(n)HardPrefix Sum, Heap, DP
4004Minimum Moves to Balance Circular Array IIC++ PythonO(n^2 * logn)O(n)Hard🔒, variant of Codeforces Round #13 CL1 Isotonic Regression, Heap, Greedy, Graph, Min-Cost Max-Flow, MCMF, Successive Shortest Path, SSP, Dijkstra's Algorithm, Johnson Potential


Tree

#TitleSolutionTimeSpaceDifficultyTagNote
3109Find the Index of PermutationC++ PythonO(nlogn)O(n)Medium🔒, variant of Count of Smaller Numbers After SelfBIT, Fenwick Tree, Combinatorics
3515Shortest Path in a Weighted TreeC++ PythonO(nlogn)O(n)HardBIT, Fenwick Tree, DFS
3553Minimum Weighted Subgraph With the Required Paths IIC++ PythonO(n + q)O(n + q)HardTree, DFS, Tarjan's Offline LCA Algorithm
3558Number of Ways to Assign Edge Weights IC++ PythonO(n)O(n)MediumTree, BFS, Combinatorics
3559Number of Ways to Assign Edge Weights IIC++ PythonO(n + q)O(n + q)MediumTree, DFS, Tarjan's Offline LCA Algorithm, Combinatorics
3585Find Weighted Median Node in TreeC++ PythonO(n + qlogh)O(n + q)HardTree, DFS, Tarjan's Offline LCA Algorithm, Binary Search, Prefix Sum
3715Sum of Perfect Square AncestorsC++ Pythonprecompute: O(r)
runtime: O(nlogx)
O(r + n)HardTree, Number Theory, Linear Sieve of Eratosthenes, Freq Table, DFS
3841Palindromic Path Queries in a TreeC++ PythonO((n + q) * logn)O(n)HardDFS, HLD, Heavy-Light Decomposition, LCA, Binary Lifting, BIT, Fenwick Tree
3879Maximum Distinct Path Sum in a Binary TreeC++ PythonO(n^2)O(n)MediumDFS, BFS
3973Distinct Gate Paths to LCAC++ PythonO(nlogn + qlogn)O(nlogn)Hard🔒DFS, LCA, Binary Lifting
3997Count Dominant Nodes in a Binary TreeC++ PythonO(n)O(h)MediumDFS


Hash Table

#TitleSolutionTimeSpaceDifficultyTagNote
3005Count Elements With Maximum FrequencyC++ PythonO(n)O(n)EasyFreq Table
3039Apply Operations to Make String EmptyC++ PythonO(n)O(1)MediumFreq Table
3044Most Frequent PrimeC++ Pythonprecompute: O(10^MAX_N_M)
runtime: O(n * m * (n + m))
O(10^MAX_N_M + n * m * (n + m))MediumNumber Theory, Linear Sieve of Eratosthenes, Freq Table
3046Split the ArrayC++ PythonO(n)O(n)EasyFreq Table
3078Match Alphanumerical Pattern in Matrix IC++ PythonO(n * m * r * c)O(1)Medium🔒Brute Force, Hash Table
3083Existence of a Substring in a String and Its ReverseC++ PythonO(n)O(min(n, 26^2))EasyHash Table
3120Count the Number of Special Characters IC++ PythonO(n + 26)O(26)EasyHash Table
3121Count the Number of Special Characters IIC++ PythonO(n + 26)O(26)MediumHash Table
3137Minimum Number of Operations to Make Word K-PeriodicC++ PythonO(n)O(n)MediumFreq Table
3138Minimum Length of Anagram ConcatenationC++ PythonO(sqrt(n) * n + 26 * nlogn)O(26)MediumNumber Theory, Freq Table
3143Maximum Points Inside the SquareC++ PythonO(n + 26)O(26)MediumHash Table
3146Permutation Difference between Two StringsC++ PythonO(n + 26)O(26)EasyHash Table
3158Find the XOR of Numbers Which Appear TwiceC++ PythonO(n)O(n)EasyHash Table
3160Find the Number of Distinct Colors Among the BallsC++ PythonO(q)O(q)MediumFreq Table
3167Better Compression of StringC++ PythonO(n + 26)O(26)Medium🔒Freq Table, Counting Sort
3184Count Pairs That Form a Complete Day IC++ PythonO(n + 24)O(24)EasyFreq Table
3185Count Pairs That Form a Complete Day IIC++ PythonO(n + 24)O(24)MediumFreq Table
3223Minimum Length of String After OperationsC++ PythonO(n + 26)O(26)MediumFreq Table
3237Alt and Tab SimulationC++ PythonO(n)O(n)Medium🔒Hash Table
3238Find the Number of Winning PlayersC++ PythonO(p)O(min(n * c, p)EasyFreq Table
3245Alternating Groups IIIC++ PythonO(nlogn + qlogn)O(n)HardBST, Sorted List, Freq Table, BIT, Fenwick Tree
3295Report Spam MessageC++ PythonO(n + m)O(m)MediumHash Table
3365Rearrange K Substrings to Form Target StringC++ PythonO(n)O(n)MediumFreq Table
3371Identify the Largest Outlier in an ArrayC++ PythonO(n)O(n)MediumFreq Table
3396Minimum Number of Operations to Make Elements in Array DistinctC++ PythonO(n + r)O(r)EasyFreq Table
3404Count Special SubsequencesC++ PythonO(n^2)O(n^2)MediumFreq Table, Number Theory
3438Find Valid Pair of Adjacent Digits in StringC++ PythonO(n)O(1)EasyFreq Table
3442Maximum Difference Between Even and Odd Frequency IC++ PythonO(n + 26)O(26)EasyFreq Table
3450Maximum Students on a Single BenchC++ PythonO(n)O(n)Easy🔒Hash Table, Unordered Set
3471Find the Largest Almost Missing IntegerC++ PythonO(n)O(n)EasyFreq Table
3487Maximum Unique Subarray Sum After DeletionC++ PythonO(n)O(n)EasyHash Table
3488Closest Equal Element QueriesC++ PythonO(n)O(n)MediumHash Table
3527Find the Most Common ResponseC++ PythonO(n * l)O(n * l)MediumHash Table, Freq Table
3541Find Most Frequent Vowel and ConsonantC++ PythonO(n + 26)O(26)EasyFreq Table
3572Maximize Y‑Sum by Picking a Triplet of Distinct X‑ValuesC++ PythonO(n)O(n)MediumHash Table, Quick Select
3581Count Odd Letters from NumberC++ PythonO(logn)O(26)Easy🔒Freq Table
3591Check if Any Element Has Prime FrequencyC++ Pythonprecompute: O(MAX_N)
runtime: O(n)
O(MAX_N)EasyFreq Table, Number Theory, Linear Sieve of Eratosthenes
3636Threshold Majority QueriesC++ PythonO(nlogn + qlogq + (n + q) * sqrt(n) * logn)O(q + n)HardSort, Coordinate Compression, Sqrt Decomposition, Mo's Algorithm, Freq Table, Sorted List, BST
3662Filter Characters by FrequencyC++ PythonO(n + 26)O(26)Easy🔒Freq Table
3663Find The Least Frequent DigitC++ PythonO(logn + 10)O(10)EasyFreq Table
3668Restore Finishing OrderC++ PythonO(n + min(8, n))O(min(8, n))EasyHash Table
3678Smallest Absent Positive Greater Than AverageC++ PythonO(n)O(n)EasyHash Table
3682Minimum Index Sum of Common ElementsC++ PythonO(n + m)O(n)Medium🔒Hash Table
3692Majority Frequency CharactersC++ PythonO(n + 26)O(26)EasyFreq Table
3694Distinct Points Reachable After Substring RemovalC++ PythonO(n)O(n)MediumHash Table
3712Sum of Elements With Frequency Divisible by KC++ PythonO(n)O(n)EasyFreq Table
3713Longest Balanced Substring IC++ PythonO(n * (a + n))O(a)MediumFreq Table
3714Longest Balanced Substring IIC++ PythonO(n)O(n)MediumHash Table, Prefix Sum
3718Smallest Missing Multiple of KC++ PythonO(n)O(n)EasyHash Table
3728Stable Subarrays With Equal Boundary and Interior SumC++ PythonO(n)O(n)MediumFreq Table, Prefix Sum
3729Count Distinct Subarrays Divisible by K in Sorted ArrayC++ PythonO(n)O(min(n, k))HardFreq Table, Prefix Sum
3755Find Maximum Balanced XOR Subarray LengthC++ PythonO(n)O(n)MediumHash Table, Prefix Sum
3760Maximum Substrings With Distinct StartC++ PythonO(n + 26)O(26)MediumHash Table
3761Minimum Absolute Distance Between Mirror PairsC++ PythonO(nlogr)O(n)MediumHash Table
3773Maximum Number of Equal Length RunsC++ PythonO(n)O(sqrt(n))Medium🔒Freq Table
3779Minimum Number of Operations to Have Distinct ElementsC++ PythonO(n)O(n)MediumHash Table
3784Minimum Deletion Cost to Make All Characters EqualC++ PythonO(n + 26)O(26)MediumFreq Table
3803Count Residue PrefixesC++ PythonO(n + 26)O(26)EasyHash Table
3804Number of Centered SubarraysC++ PythonO(n^2)O(n)MediumHash Table
3805Count Caesar Cipher PairsC++ PythonO(n * m)O(n * m)MediumFreq Table
3810Minimum Operations to Reach Target ArrayC++ PythonO(n)O(n)MediumHash Table
3837Delayed Count of Equal ElementsC++ PythonO(n)O(n)Medium🔒Freq Table
3839Number of Prefix Connected GroupsC++ PythonO(n * k)O(n * k)MediumFreq Table
3842Toggle Light BulbsC++ PythonO(n + r)O(r)EasyFreq Table, Sort
3843First Element with Unique FrequencyC++ PythonO(n)O(n)MediumFreq Table
3846Total Distance to Type a String Using One FingerC++ PythonO(n)O(n)Medium🔒Hash Table
3848Check Digitorial PermutationC++ PythonO(logn + 10)O(10)MediumFreq Table
3852Smallest Pair With Different FrequenciesC++ PythonO(n)O(n)EasyFreq Table
3866First Unique Even ElementC++ PythonO(n)O(n)EasyFreq Table
3889Mirror Frequency DistanceC++ PythonO(n + 36)O(36)MediumFreq Table
3890Integers With Multiple Sum of Two CubesC++ PythonO(n^(2/3) * logn)O(n^(2/3))MediumBrute Force, Freq Table, Sort
3900Longest Balanced Substring After One SwapC++ PythonO(n)O(n)Mediumvariant of Contiguous ArrayHash Table
3901Good Subsequence QueriesC++ Pythonprecompute: O(rlog(logr))
runtime: O(r + n + q)
O(rlog(logr) + n)MediumNumber Theory, Freq Table
3913Sort Vowels by FrequencyC++ PythonO(n)O(1)MediumFreq Table, Sort
3917Count Indices With Opposite ParityC++ PythonO(n)O(1)EasyFreq Table
3921Score ValidatorC++ PythonO(n)O(1)EasyFreq Table
3926Count Valid Word OccurrencesC++ PythonO(n)O(n)MediumFreq Table
3945Digit Frequency ScoreC++ PythonO(logn)O(1)EasyFreq Table
3960Frequency Balance SubarrayC++ PythonO(n^2)O(n)MediumSort, Coordinate Compression, Freq Table
4007Widest Possible FenceC++ PythonO(n + c^2)O(c^2)MediumFreq Table
4038Count Integers Appearing in a Single BlockC++ PythonO(n)O(n)EasyFreq Table
4048Count Values With Equally Spaced Occurrences IC++ PythonO(n)O(n)EasyHash Table
4049Count Values With Equally Spaced Occurrences IIC++ PythonO(n)O(n)MediumHash Table
4066Maximum Equal Adjacent Pairs After at Most One ReplacementC++ PythonO(n)O(n)MediumFreq Table


Math

#TitleSolutionTimeSpaceDifficultyTagNote
3001Minimum Moves to Capture The QueenC++ PythonO(1)O(1)MediumMath
3007Maximum Number That Sum of the Prices Is Less Than or Equal to KC++ PythonO(max(logk, x) * log((logk) / x))O((logk) / x)MediumBit Manipulation, Binary Search, Combinatorics
3021Alice and Bob Playing Flower GameC++ PythonO(1)O(1)MediumCombinatorics
3024Type of Triangle IIC++ PythonO(1)O(1)EasyMath
3032Count Numbers With Unique Digits IIC++ PythonO(logb)O(1)Easy🔒, variant of Count Numbers With Unique DigitsBrute Force, Hash Table, Bitmasks, Combinatorics
3047Find the Largest Area of Square Inside Two RectanglesC++ PythonO(n^2)O(1)MeidumBrute Force, Math
3084Count Substrings Starting and Ending with Given CharacterC++ PythonO(n)O(1)MeidumCombinatorics
3091Apply Operations to Make Sum of Array Greater Than or Equal to kC++ PythonO(logn)O(1)MeidumCodeforces Round #674 CMath
3099Harshad NumberC++ PythonO(logx)O(1)EasyMath
3102Minimize Manhattan DistancesC++ PythonO(n)O(1)HardMath
3115Maximum Prime DifferenceC++ PythonO(r + n)O(r)MediumArray, Number Theory, Linear Sieve of Eratosthenes
3128Right TrianglesC++ PythonO(n * m)O(min(n, m))MediumArray, Combinatorics, Freq Table
3154Find Number of Ways to Reach the K-th StairC++ PythonO(logk)O(logk)HardCombinatorics
3155Maximum Number of Upgradable ServersC++ PythonO(n)O(1)Medium🔒Math
3162Find the Number of Good Pairs IC++ PythonO(rlogr + n + m)O(r)EasyBrute Force, Number Theory, Freq Table
3164Find the Number of Good Pairs IIC++ PythonO(rlogr + n + m)O(r)MediumNumber Theory, Freq Table
3178Find the Child Who Has the Ball After K SecondsC++ PythonO(1)O(1)EasyMath
3179Find the N-th Value After K SecondsC++ PythonO(n + k)O(n + k)MediumPrefix Sum, Combinatorics
3183The Number of Ways to Make the SumC++ PythonO(1)O(1)Medium🔒Math, DP
3190Find Minimum Operations to Make All Elements Divisible by ThreeC++ PythonO(n)O(1)EasyMath
3200Maximum Height of a TriangleC++ PythonO(logn)O(1)EasySimulation, Math
3222Find the Winning Player in Coin GameC++ PythonO(1)O(1)EasyMath
3227Vowels Game in a StringC++ PythonO(n)O(1)MediumMath
3232Find if Digit Game Can Be WonC++ PythonO(n)O(1)EasyBrute Force, Game Theory
3247Number of Subsequences with Odd SumC++ PythonO(n)O(1)Medium🔒Combinatorics, Fast Exponentiation, DP
3250Find the Count of Monotonic Pairs IC++ PythonO(n + r)O(n + r)HardCombinatorics, Stars and Bars, DP, Prefix Sum
3251Find the Count of Monotonic Pairs IIC++ PythonO(n + r)O(n + r)HardCombinatorics, Stars and Bars, DP, Prefix Sum
3270Find the Key of the NumbersC++ PythonO(d)O(1)EasyMath
3272Find the Count of Good IntegersC++ PythonO(n + 10 * 10^((n + 1)/2))O(n + 10 * (10 * nHr(10, n/2)))HardCombinatorics, Freq Table
3274Check if Two Chessboard Squares Have the Same ColorC++ PythonO(1)O(1)EasyMath, Parity
3284Sum of Consecutive SubarraysC++ PythonO(n)O(1)Medium🔒Combinatorics
3299Sum of Consecutive SubsequencesC++ PythonO(n)O(n)Hard🔒Combinatorics, Prefix Sum, DP
3312Sorted GCD Pair QueriesC++ PythonO(rlogr + qlogr)O(r)HardNumber Theory, Freq Table, Prefix Sum, Binary Search
3317Find the Number of Possible Ways for an EventC++ Pythonprecompute: 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))HardDP, Combinatorics
3326Minimum Division Operations to Make Array Non DecreasingC++ Pythonprecompute: O(r)
runtime: O(n)
O(r)MediumGreedy, Number Theory, Linear Sieve of Eratosthenes
3339Find the Number of K-Even ArraysC++ PythonO(n)O(n)Medium🔒DP, Stars and Bars, Combinatorics
3345Smallest Divisible Digit Product IC++ PythonO(logn)O(1)EasyBrute Force
3348Smallest Divisible Digit Product IIC++ PythonO(n + logt)O(1)HardFreq Table, Greedy, Prefix Sum, Number Theory
3360Stone Removal GameC++ PythonO(1)O(1)EasyMath
3395Subsequences with a Unique Middle Mode IC++ PythonO(n)O(n)HardFreq Table, Prefix Sum, Combinatorics
3405Count the Number of Arrays with K Matching Adjacent ElementsC++ PythonO(n + logm)O(n)HardCombinatorics, Fast Exponentiation
3411Maximum Subarray With Equal ProductsC++ Pythonprecompute: O(r * log(logr))
runtime: O(n * log(logr))
O(r * log(logr))EasyNumber Theory, Linear Sieve of Eratosthenes, Hash Table
3416Subsequences with a Unique Middle Mode IIC++ PythonO(n)O(n)Hard🔒Freq Table, Prefix Sum, Combinatorics
3426Manhattan Distances of All Arrangements of PiecesC++ Pythonprecompute: O(max(m * n))
runtime: O(1)
O(max(m * n))HardCombinatorics
3428Maximum and Minimum Sums of at Most Size K SubsequencesC++ PythonO(nlogn)O(n)MediumSort, Combinatorics, Two Pointers, Sliding Window
3447Assign Elements to Groups with ConstraintsC++ PythonO(m + r * logn)O(r)MediumHash Table, Number Theory
3448Count Substrings Divisible By Last DigitC++ PythonO(d * n)O(d)HardDP, Case Works, Math, Freq Table
3461Check If Digits Are Equal in String After Operations IC++ PythonO(nlogn)O(1)EasyFast Exponentiation, Luca's Theorem, Simulation
3463Check If Digits Are Equal in String After Operations IIC++ PythonO(nlogn)O(1)HardFast Exponentiation, Lucas's Theorem
3470Permutations IVC++ PythonO(n^2)O(n)HardCombinatorics
3483Unique 3-Digit Even NumbersC++ PythonO(n)O(1)EasyFreq Table, Combinatorics
3492Maximum Containers on a ShipC++ PythonO(1)O(1)EasyMath
3512Minimum Operations to Make Array Sum Divisible by KC++ PythonO(n)O(1)EasyMath
3513Number of Unique XOR Triplets IC++ PythonO(logn)O(1)MediumBit Manipulation, Math
3516Find Closest PersonC++ PythonO(1)O(1)EasyMath
3519Count Numbers with Non-Decreasing DigitsC++ PythonO(n^2)O(n)HardMath, Stars and Bars, Combinatorics
3556Sum of Largest Prime SubstringsC++ PythonO(n^2 * sqrt(r))O(n^2)MediumNumber Theory, Quick Select
3560Find Minimum Log Transportation CostC++ PythonO(1)O(1)EasyMath
3577Count the Number of Computer Unlocking PermutationsC++ PythonO(n)O(1)MediumCombinatorics
3588Find Maximum Area of a TriangleC++ PythonO(n)O(n)MediumMath, Hash Table
3596Minimum Cost Path with Alternating Directions IC++ PythonO(1)O(1)Medium🔒Math
3602Hexadecimal and Hexatrigesimal ConversionC++ PythonO(logn)O(1)EasyMath
3618Split Array by Prime IndicesC++ Pythonprecompute: O(max_n)
runtime: O(n)
O(max_n)MediumNumber Theory, Linear Sieve of Eratosthenes
3621Number of Integers With Popcount-Depth Equal to K IC++ Pythonprecompute: O((logr)^2)
runtime: O((logn)^2)
O((logr)^2)HardCombinatorics
3622Check Divisibility by Digit Sum and ProductC++ PythonO(logn)O(1)EasyMath
3623Count Number of Trapezoids IC++ PythonO(n)O(n)MediumFreq Table, Combinatorics
3624Number of Integers With Popcount-Depth Equal to K IIC++ Pythonprecompute: O((logr) * log(logr))
runtime: O(nlogr + max_k * n + nlogn + qlogn)
O(logr + max_k * n)HardBIT, Fenwick Tree
3625Count Number of Trapezoids IIC++ PythonO(n^2 * logr)O(n^2)HardFreq Table, Combinatorics
3648Minimum Sensors to Cover GridC++ PythonO(1)O(1)MediumMath
3658GCD of Odd and Even SumsC++ PythonO(1)O(1)EasyMath
3659Partition Array Into K-Distinct GroupsC++ PythonO(n)O(n)MediumMath, Freq Table
3664Two-Letter Card GameC++ PythonO(n + 26)O(26)MediumMath, Freq Table
3666Minimum Operations to Equalize Binary StringC++ PythonO(n)O(1)HardMath
3671Sum of Beautiful SubsequencesC++ Pythonprecompute: O(rlogr)
runtime: O(nlogr * (log(nlogr) + logn))
O(rlogr)HardNumber Theory, BIT, Fenwick Tree
3677Count Binary Palindromic NumbersC++ PythonO(logn)O(1)HardBitmasks, Combinatorics
3697Compute Decimal RepresentationC++ PythonO(logn)O(1)EasyMath
3726Remove Zeros in Decimal RepresentationC++ PythonO(logn)O(1)EasyMath, String
3731Find Missing ElementsC++ PythonO(n + r)O(n)EasyHash Table
3745Maximize Expression of Three ElementsC++ PythonO(n)O(1)EasyMath
3747Count Distinct Integers After Removing ZerosC++ PythonO(logn)O(1)MediumCombinatorics
3754Concatenate Non-Zero Digits and Multiply by Sum IC++ PythonO(logn)O(1)EasyMath
3765Complete Prime NumberC++ PythonO(logn * sqrt(n))O(1)MediumPrefix Sum, Number Theory
3770Largest Prime from Consecutive Prime SumC++ Pythonprecompute: O(r)
runtime: O(logp)
O(sqrt(r))MediumPrecompute, Number Theory, Linear Sieve of Eratosthenes, Binary Search
3783Mirror Distance of an IntegerC++ PythonO(logn)O(1)EasyMath
3789Minimum Cost to Acquire Required ItemsC++ PythonO(1)O(1)MediumMath
3790Smallest All-Ones MultipleC++ PythonO(k)O(1)Mediumduplicate of Smallest Integer Divisible by KMath
3798Largest Even NumberC++ PythonO(n)O(1)EasyMath
3800Minimum Cost to Make Two Binary Strings EqualC++ PythonO(n)O(1)MediumMath
3817Good Indices in a Digit StringC++ PythonO(n)O(1)Medium🔒Math, Sliding Window
3821Find Nth Smallest Integer With K One BitsC++ Pythonctor: O(r^2)
runtime: O(r)
O(r^2)HardDP, Combinatorics
3855Sum of K-Digit Numbers in a RangeC++ PythonO(logr)O(1)HardMath
3857Minimum Cost to Split into OnesC++ PythonO(1)O(1)MediumCombinatorics
3870Count Commas in RangeC++ PythonO(logn)O(1)EasyMath
3871Count Commas in Range IIC++ PythonO(logn)O(1)MediumMath
3881Direction Assignments with Exactly K Visible PeopleC++ PythonO(n)O(n)MediumCombinatorics
3895Count Digit AppearancesC++ PythonO(nlogr)O(1)MediumMath
3896Count Digit AppearancesC++ Pythonprecompute: O(r), runtime: O(nlogn)O(r)MediumNumber Theory, Linear Sieve of Eratosthenes, Prime Gap, Binary Search
3899Angles of a TriangleC++ PythonO(1)O(1)MediumMath, Law of Cosines
3908Valid Digit NumberC++ PythonO(logn)O(1)EasyMath
3927Minimize Array Sum Using Divisible ReplacementsC++ PythonO(n + rlogr)O(r)MediumNumber Theory
3954Sum of Compatible Numbers in Range IC++ PythonO(log(n + k))O(1)EasyBitmasks, Combinatorics, Simulation
3958Minimum Cost to Split into Ones IIC++ PythonO(1)O(1)Medium🔒Math, Invariant
3959Check Good IntegerC++ PythonO(logn)O(1)EasyMath
3984Divisible GameC++ Pythonprecompute: O(r)
runtime: O(nlogx)
O(r + n)MediumNumber Theory, Linear Sieve of Eratosthenes, Kadane's Algorithm, Prefix Sum
3987Minimum Total Cost to Process All ElementsC++ PythonO(n)O(1)MediumMath
3993Maximum Value of an Alternating SequenceC++ PythonO(1)O(1)MediumMath
3996Even Number of Knight MovesC++ PythonO(1)O(1)EasyMath, Parity
4002Count Valid SequencesC++ PythonO(n)O(n)MediumCombinatorics, Stars and Bars
4022K-th Digit in Infinite StringC++ PythonO(logk)O(1)MediumMath
4034Minimum Bishop Moves to Reach TargetC++ PythonO(1)O(1)MediumMath
4035Maximum Valid Split Positions IC++ PythonO(n)O(n)MediumNumber Theory, Prefix Sum
4037Maximum Valid Split Positions IIC++ PythonO(n)O(n)HardNumber Theory, Prefix Sum
4039Sum of Decoded NumbersC++ PythonO(nlogr)O(1)MediumFast Exponentiation
4060Count Evenly Good IntegersC++ PythonO(logr)O(1)Hard🔒Math
4061Minimum Queen Moves to Reach TargetC++ PythonO(1)O(1)EasyMath


Sort

#TitleSolutionTimeSpaceDifficultyTagNote
3011Find if Array Can Be SortedC++ PythonO(n)O(1)MediumSort
3025Find the Number of Ways to Place People IC++ PythonO(n^2)O(1)MediumSort, Array
3027Find the Number of Ways to Place People IIC++ PythonO(n^2)O(1)HardSort, Array
3081Replace Question Marks in String to Minimize Its ValueC++ PythonO(n + 26 * log(26))O(n + 26)MediumGreedy, Counting Sort, Heap, Prefix Sum
3132Find the Integer Added to Array IIC++ PythonO(n)O(n)MediumSort, Paritial Sort, Freq Table
3169Count Days Without MeetingsC++ PythonO(nlogn)O(1)MediumSort
3194Minimum Average of Smallest and Largest ElementsC++ PythonO(nlogn)O(1)EasySort
3309Maximum Possible Number by Binary ConcatenationC++ PythonO(n * logr * logn)O(nlogr)MediumSort, Brute Force
3394Check if Grid can be Cut into SectionsC++ PythonO(nlogn)O(1)MediumSort, Merge Intervals
3431Minimum Unlocked Indices to Sort NumsC++ PythonO(n)O(1)MediumSort
3551Minimum Swaps to Sort by Digit SumC++ PythonO(nlogr + nlogn)O(n)MediumSort
3631Sort Threats by Severity and ExploitabilityC++ PythonO(nlogn)O(1)Medium🔒Sort
3644Maximum K to Sort a PermutationC++ PythonO(n)O(1)MediumSort, Bitmasks, Constructive Algorithms
3667Sort Array By Absolute ValueC++ PythonO(n + r)O(n + r)Easy🔒Sort
3759Count Elements With at Least K Greater ValuesC++ PythonO(n)O(1)MediumSort, Quick Select
3780Maximum Sum of Three Numbers Divisible by ThreeC++ PythonO(n)O(1)MediumSort, Math
3799Word Squares IIC++ PythonO(n^4)O(1)MediumSort, Brute Force, Hash Table
3975Filter Occupied IntervalsC++ PythonO(nlogn)O(n)MediumSort
4065Rearrange Array by Removing Distinct ValuesC++ PythonO(nlogn)O(n)EasyFreq Table, Sort
4068Maximize Meeting Earnings with Idle GapsC++ PythonO(nlogn)O(n)HardSort, Two Pointers, Binary Search, Prefix Sum


Two Pointers

#TitleSolutionTimeSpaceDifficultyTagNote
3006Find Beautiful Indices in the Given Array IC++ PythonO(n)O(min(a + b + x + y, n))MediumKMP Algorithm, Binary Search, Two Pointers
3008Find Beautiful Indices in the Given Array IIC++ PythonO(n)O(min(a + b + x + y, n))HardKMP Algorithm, Binary Search, Two Pointers
3013Divide an Array Into Subarrays With Minimum Cost IIC++ PythonO(nlogd)O(d)HardSliding Window, Heap, Freq Table, Ordered Set, BST, Sorted List
3085Minimum Deletions to Make String K-SpecialC++ PythonO(n + 26)O(n + 26)MediumFreq Table, Counting Sort, Two Pointers
3090Maximum Length Substring With Two OccurrencesC++ PythonO(n + 26)O(26)EasyFreq Table, Sliding Window, Two Pointers
3095Shortest Subarray With OR at Least K IC++ PythonO(n * 30)O(30)EasyBrute Force, Freq Table, Two Pointers
3097Shortest Subarray With OR at Least K IIC++ PythonO(n * 30)O(30)MediumFreq Table, Two Pointers
3171Find Subarray With Bitwise OR Closest to KC++ PythonO(nlogr)O(logr)Hardvariant of Find a Value of a Mysterious Function Closest to TargetDP, Freq Table, Two Pointers, Sliding Window
3206Alternating Groups IC++ PythonO(n)O(1)EasyTwo Pointers, Sliding Window
3208Alternating Groups IIC++ PythonO(n)O(1)MediumTwo Pointers, Sliding Window
3234Count the Number of Substrings With Dominant OnesC++ PythonO(n^(3/2))O(1)MediumTwo Pointers, Sliding Window
3254Find the Power of K-Size Subarrays IC++ PythonO(n)O(1)MediumTwo Pointers, Sliding Window
3255Find the Power of K-Size Subarrays IIC++ PythonO(n)O(1)MediumTwo Pointers, Sliding Window
3258Count Substrings That Satisfy K-Constraint IC++ PythonO(n)O(1)EasyTwo Pointers, Sliding Window
3261Count Substrings That Satisfy K-Constraint IIC++ PythonO(n)O(n)HardTwo Pointers, Sliding Window, Prefix Sum, Hash Table
3264Final Array State After K Multiplication Operations IC++ PythonO(nlogn)O(n)EasySort, Two Pointers, Sliding Window, Fast Exponentiation, Heap, Binary Search, Simulation
3266Final Array State After K Multiplication Operations IIC++ PythonO(nlogn)O(n)HardSort, Two Pointers, Sliding Window, Fast Exponentiation, Heap, Binary Search
3297Count Substrings That Can Be Rearranged to Contain a String IC++ PythonO(n + 26)O(26)MediumTwo Pointers, Sliding Window, Freq Table
3298Count Substrings That Can Be Rearranged to Contain a String IIC++ PythonO(n + 26)O(26)HardTwo Pointers, Sliding Window, Freq Table
3305Count of Substrings Containing Every Vowel and K Consonants IC++ PythonO(n)O(1)MediumTwo Pointers, Sliding Window, Freq Table
3306Count of Substrings Containing Every Vowel and K Consonants IIC++ PythonO(n)O(1)MediumTwo Pointers, Sliding Window, Freq Table
3318Find X-Sum of All K-Long Subarrays IC++ PythonO(nlogn)O(n)EasyTwo Pointers, Sliding Window, Freq Table, Ordered Set, Sorted List
3321Find X-Sum of All K-Long Subarrays IIC++ PythonO(nlogn)O(n)HardTwo Pointers, Sliding Window, Freq Table, Ordered Set, Sorted List
3323Minimize Connected Groups by Inserting IntervalC++ PythonO(nlogn)O(n)Medium🔒Sort, Prefix Sum, Two Pointers, Sliding Window
3325Count Substrings With K-Frequency Characters IC++ PythonO(n + 26)O(26)MediumFreq Table, Two Pointers, Sliding Window
3329Count Substrings With K-Frequency Characters IIC++ PythonO(n + 26)O(26)Hard🔒Freq Table, Two Pointers, Sliding Window
3346Maximum Frequency of an Element After Performing Operations IC++ PythonO(nlogn)O(n)MediumSort, Freq Table, Two Pointers, Sliding Window, Difference Array, Line Sweep
3347Maximum Frequency of an Element After Performing Operations IIC++ PythonO(nlogn)O(n)HardSort, Freq Table, Two Pointers, Sliding Window, Difference Array, Line Sweep
3364Minimum Positive Sum SubarrayC++ PythonO(nlogn)O(n)EasyPrefix Sum, Two Pointers, Sliding Window, Sorted List, BST, Binary Search
3413Maximum Coins From K Consecutive BagsC++ PythonO(nlogn)O(1)MediumSort, Two Pointers, Sliding Window
3420Count Non-Decreasing Subarrays After K OperationsC++ PythonO(n)O(n)HardMono Deque, Two Pointers, Sliding Window
3422Minimum Operations to Make Subarray Elements EqualC++ PythonO(nlogk)O(k)Medium🔒Math, Two Pointers, Sliding Window, Sorted List, BST
3425Longest Special PathC++ PythonO(n + e)O(n + e)HardDFS, Two Pointers, Sliding Window, Prefix Sum
3430Maximum and Minimum Sums of at Most Size K SubarraysC++ PythonO(n)O(k)HardTwo Pointers, Sliding Window, Mono Deque
3439Reschedule Meetings for Maximum Free Time IC++ PythonO(n)O(1)MediumTwo Pointers, Sliding Window
3445Maximum Difference Between Even and Odd Frequency IIC++ PythonO(d^2 * n)O(n)HardPrefix Sum, Two Pointers, Sliding Window
3460Longest Common Prefix After at Most One RemovalC++ PythonO(n)O(1)Medium🔒Two Pointers
3485Longest Common Prefix of K Strings After RemovalC++ PythonO(l * nlogn)O(n)HardSort, Sliding Window, Prefix Sum, Trie
3486Longest Special Path IIC++ PythonO(n + e)O(n + e)HardDFS, Two Pointers, Sliding Window, Prefix Sum
3555Smallest Subarray to Sort in Every Sliding WindowC++ PythonO(n)O(n)Medium🔒Mono Stack, Two Pointers
3567Minimum Absolute Difference in Sliding SubmatrixC++ PythonO(m * n * k^2)O(k^2)MediumBrute Force, Sort, Two Pointers, Sliding Window, BST, Sorted List
3584Maximum Product of First and Last Elements of a SubsequenceC++ PythonO(n)O(1)MediumTwo Pointers, Sliding Window
3589Count Prime-Gap Balanced SubarraysC++ Pythonprecompute: O(r)
runtime: O(n)
O(r)MediumNumber Theory, Linear Sieve of Eratosthenes, Mono Deque, Two Pointers, Sliding Window
3634Minimum Removals to Balance ArrayC++ PythonO(nlogn)O(1)MediumSort, Two Pointers, Sliding Window
3640Trionic Array IIC++ PythonO(n)O(1)EasyTwo Pointers, Sliding Window, Greedy
3641Longest Semi-Repeating SubarrayC++ PythonO(n)O(1)Medium🔒Freq Table, Two Pointers, Sliding Window
3649Number of Perfect PairsC++ PythonO(nlogn)O(1)MediumSort, Two Pointers, Sliding Window, Math
3652Best Time to Buy and Sell Stock using StrategyC++ PythonO(n)O(1)MediumTwo Pointers, Sliding Window
3672Sum of Weighted Modes in SubarraysC++ PythonO(nlogk)O(k)Medium🔒Sorted List, BST, Two Pointers, Sliding Window
3679Minimum Discards to Balance InventoryC++ PythonO(n)O(w)MediumFreq Table, Two Pointers, Sliding Window
3698Split Array With Minimum DifferenceC++ PythonO(n)O(1)MediumTwo Pointers
3740Minimum Distance Between Three Equal Elements IC++ PythonO(n)O(n)EasyHash Table, Two Pointers, Sliding Window
3741Minimum Distance Between Three Equal Elements IIC++ PythonO(n)O(n)MediumHash Table, Two Pointers, Sliding Window
3768Minimum Inversion Count in Subarrays of Fixed LengthC++ PythonO(nlogn)O(n)HardSort, Coordinate Compression, BIT, Fenwick Tree, Two Pointers, Sliding Window
3795Minimum Subarray Length With Distinct Sum At Least KC++ PythonO(n)O(n)MediumFreq Table, Two Pointers, Sliding Window
3802Number of Ways to Paint SheetsC++ PythonO(mlogm)O(m)Hard🔒Prefix Sum, Two Pointers
3835Count Subarrays With Cost Less Than or Equal to KC++ PythonO(n)O(n)MediumMono Deque, Two Pointers, Sliding Window
3844Longest Almost-Palindromic SubstringC++ PythonO(n^2)O(1)MediumTwo Pointers
3845Maximum Subarray XOR with Bounded RangeC++ PythonO(nlogr)O(n)HardTwo Pointers, Sliding Window, Mono Deque, Bitmasks, Prefix Sum, Trie, Hash Table
3851Maximum Requests Without Violating the LimitC++ PythonO(nlogn)O(n)Medium🔒Hash Table, Sort, Deque, Two Pointers, Sliding Window
3859Count Subarrays With K Distinct IntegersC++ PythonO(n)O(n)HardFreq Table, Two Pointers, Sliding Window
3872Longest Arithmetic Sequence After Changing At Most One ElementC++ PythonO(n)O(1)MediumTwo Pointers
3874Valid Subarrays With Exactly One PeakC++ PythonO(n)O(1)Medium🔒Combinatorics, Two Pointers
3937Minimum Operations to Make Array Modulo Alternating IC++ PythonO(n + k)O(k)MediumFreq Table, Two Pointers, Sliding Window
3944Minimum Operations to Make Array Modulo Alternating IIC++ PythonO(n + k)O(k)Hard🔒Freq Table, Two Pointers, Sliding Window
3969Valid Subarrays With Matching Sum Digits IC++ PythonO(nlogr)O(n)MediumBrute Force, Prefix Sum, Two Pointers, Sliding Window
3972Valid Subarrays With Matching Sum Digits IIC++ PythonO(nlogr)O(n)Hard🔒Prefix Sum, Two Pointers, Sliding Window
3992Rearrange String to Avoid Character PairC++ PythonO(n)O(1)EasyTwo Pointers
4001Aggregate Two Time SeriesC++ PythonO(n + m)O(1)MediumTwo Pointers
4031Find All Numbers Disappeared in an Array IIC++ PythonO(r)O(r)MediumSort, Two Pointers, Hash Table
4032Longest Subarray With at Most K Distinct Prime FactorsC++ Pythonctor: O(r)
runtime: O(nlogr)
O(r)MediumNumber Theory, Linear Sieve of Eratosthenes, Freq Table, Two Pointers, Sliding Window
4033Valid K-Unique Subarrays IC++ PythonO(n + q)O(n)HardTwo Pointers, Sliding Window, Hash Table, Prefix Sum, BIT, Fenwick Tree, Sort, Coordinate Compression, Mo's Algorithm
4042Valid K-Unique Subarrays IIC++ PythonO(n + q)O(n)Hard🔒Two Pointers, Sliding Window, Hash Table, Prefix Sum
4044Count Good Cyclic RotationsC++ PythonO(n)O(1)MediumTwo Pointers, Sliding Window
4067Longest Subarray With Restricted Pair SumsC++ PythonO(n * r)O(r)MediumFreq Table, Two Pointers, Sliding Window


Recursion

#TitleSolutionTimeSpaceDifficultyTagNote


#TitleSolutionTimeSpaceDifficultyTagNote
3048Earliest Second to Mark Indices IC++ PythonO(mlogm)O(n)MediumBinary Search, Greedy
3049Earliest Second to Mark Indices IIC++ PythonO((m + nlogn) *logm)O(n)HardBinary Search, Greedy, Heap
3104Find Longest Self-Contained SubstringC++ PythonO(n + 26^3 * logn)O(n)Hard🔒Brute Force, Freq Table, Two Pointers, Hash Table, Binary Search
3116Kth Smallest Amount With Single Denomination CombinationC++ PythonO(n * 2^n * logk)O(2^n)HardBinary Search, Principle of Inclusion and Exclusion, Number Theory
3134Find the Median of the Uniqueness ArrayC++ PythonO(nlogn)O(n)HardBinary Search, Two Pointers, Sliding Window
3135Equalize Strings by Adding or Removing Characters at EndsC++ PythonO((n + m) * log(min(n, m)))O(min(n, m))Medium🔒Binary Search, Rabin-Karp Algorithm, Rolling Hash, DP
3145Find Products of Elements of Big ArrayC++ PythonO(q * (logr)^2)O(1)HardBinary Search, Combinatorics, Bitmasks, Fast Exponentiation
3231Minimum Number of Increasing Subsequence to Be RemovedC++ PythonO(nlogn)O(n)Hard🔒, variant of Longest Increasing SubsequenceBinary Search
3233Find the Count of Numbers Which Are Not SpecialC++ Pythonprecompute: O(sqrt(r))
runtime: O(logr)
O(sqrt(r))MediumNumber Theory, Linear Sieve of Eratosthenes, Binary Search
3281Maximize Score of Numbers in RangesC++ PythonO(nlogr)O(1)MediumBinary Search, Greedy
3288Length of the Longest Increasing PathC++ PythonO(nlogn)O(n)HardSort, Binary Search, Longest Increasing Subsequence
3296Minimum Number of Seconds to Make Mountain Height ZeroC++ PythonO(nlogr)O(1)MediumBinary Search, Quadratic Equation, Heap
3356Zero Array Transformation IIC++ PythonO((n + q) * logn)O(n)MediumBinary Search, Line Sweep
3357Minimize the Maximum Adjacent Element DifferenceC++ PythonO(nlogr)O(1)HardBinary Search
3398Smallest Substring With Identical Characters IC++ PythonO(nlogn)O(1)HardBinary Search, Greedy
3399Smallest Substring With Identical Characters IIC++ PythonO(nlogn)O(1)HardBinary Search, Greedy
3449Maximize the Minimum Game ScoreC++ PythonO(n * log(m * r))O(1)HardBinary Search, Greedy
3464Maximize the Distance Between Points on a SquareC++ PythonO(nlogn + nlogs)O(n)HardSort, Binary Search, Greedy, Two Pointers, Sliding Window
3477Fruits Into Baskets IIC++ PythonO(nlogn)O(n)EasySegment Tree, Binary Search, Brute Force
3479Fruits Into Baskets IIIC++ PythonO(nlogn)O(n)MediumSegment Tree, Binary Search
3520Minimum Threshold for Inversion Pairs CountC++ PythonO(nlogn * logr)O(n)Medium🔒Binary Search, Sorted List, Ordered Set
3605Minimum Stability Factor of ArrayC++ PythonO(nlogn * logr)O(nlogn)HardNumber Theory, Binary Search, RMQ, Sparse Table, Greedy
3722Lexicographically Smallest String After ReverseC++ PythonO(nlogn)O(n)MediumString, Brute Force, Binary Search, Rabin-Karp Algorithm, Rolling Hash
3733Minimum Time to Complete All DeliveriesC++ PythonO(logr + logd)O(1)MediumBinary Search
3735Lexicographically Smallest String After Reverse IIC++ PythonO(nlogn)O(n)Hard🔒Binary Search, Rabin-Karp Algorithm, Rolling Hash
3771Total Score of Dungeon RunsC++ PythonO(nlogn)O(n)MediumPrefix Sum, Binary Search
3807Minimum Cost to Repair Edges to Traverse a GraphC++ PythonO((n + m) * logr)O(n + m)Medium🔒Binary Search, BFS
3824Minimum K to Reduce Array Within LimitC++ PythonO(nlogn + nlogr)O(1)MediumBinary Search
3825Longest Strictly Increasing Subsequence With Non-Zero Bitwise ANDC++ PythonO(logr * nlogn)O(n)MediumBitmasks, LIS, Longest Increasing Subsequence, Binary Search
3826Minimum Partition ScoreC++ PythonO(nlogn + nlogr)O(n)HardPrefix Sum, DP, Convex Hull Trick, WQS Binary Search, Alien Trick
3893Maximum Team Size with Overlapping IntervalsC++ PythonO(nlogn)O(n)Medium🔒Sort, Binary Search
3911K-th Smallest Remaining Even Integer in Subarray QueriesC++ PythonO(n + qlogn)O(n)HardPrefix Sum, Binary Search
3920Maximize Fixed Points After DeletionsC++ PythonO(nlogn)O(n)HardSort, Binary Search, Longest Increasing Subsequence
3924Minimum Threshold Path With Limited Heavy EdgesC++ PythonO((n + e) * loge)O(n + e)HardBinary Search, 0-1 BFS, Deque
3929Minimum Partition Score IIC++ PythonO(nlogn + nlogr)O(n)Hard🔒Prefix Sum, DP, Convex Hull Trick, WQS Binary Search, Alien Trick
3932Count K-th Roots in a RangeC++ PythonO(logr * logk)O(1)MediumBinary Search, Fast Exponentiation
3934Smallest Unique SubarrayC++ PythonO(nlogn)O(n)HardBinary Search, Rabin-Karp Algorithm, Rolling Hash
3956Maximum Sum of M Non-Overlapping Subarrays IC++ PythonO(nlogr)O(n)HardPrefix Sum, DP, Mono Deque, WQS Binary Search, Alien Trick
3957Maximum Sum of M Non-Overlapping Subarrays IIC++ PythonO(nlogr)O(n)HardPrefix Sum, DP, Mono Deque, WQS Binary Search, Alien Trick
3971Maximum Total ValueC++ PythonO(nlogr)O(1)HardBinary Search


Binary Search Tree

#TitleSolutionTimeSpaceDifficultyTagNote
3072Distribute Elements Into Two Arrays IIC++ PythonO(nlogn)O(n)HardSorted List, Ordered Set
3073Maximum Increasing Triplet ValueC++ PythonO(nlogn)O(n)Medium🔒Sorted List, BST, Prefix Sum
3161Block Placement QueriesC++ PythonO(qlogq)O(q)HardSorted List, BST, BIT, Fenwick Tree, Segment Tree
3165Maximum Sum of Subsequence With Non-adjacent ElementsC++ PythonO(n + qlogn)O(n)HardSegment Tree
3526Range XOR Queries with Subarray ReversalsC++ PythonO(n + qlogn)O(n)Hard🔒Treap
3930Power Update After K-th Largest Insertion IIC++ PythonO((n + q) * log(n * q) + q * logr)O(n + q)Hard🔒Sorted List, Ordered Set, Sort, Coordinate Compression, BIT, Fenwick Tree, Fast Exponentiation
3935Power Update After K-th Largest Insertion IC++ PythonO((n + q) * log(n * q) + q * logr)O(n + q)Medium🔒Sorted List, Ordered Set, Sort, Coordinate Compression, BIT, Fenwick Tree, Fast Exponentiation


#TitleSolutionTimeSpaceDifficultyTagNote
3157Find the Level of Tree with Minimum SumC++ PythonO(n)O(w)Medium🔒BFS
3286Find a Safe Walk Through a GridC++ PythonO(m * n)O(m * n)Mediumvariant of Minimum Obstacle Removal to Reach Corner0-1 BFS, Deque
3373Maximize the Number of Target Nodes After Connecting Trees IIC++ PythonO(n + m)O(n + m)HardBFS
3528Unit Conversion IC++ PythonO(n)O(n)MediumBFS
3535Unit Conversion IIC++ PythonO(n + qlogm)O(n)Medium🔒BFS, Fast Exponentiation
3552Grid Teleportation TraversalC++ PythonO(m * n)O(m * n)Medium0-1 BFS, Deque
3568Minimum Moves to Clean the ClassroomC++ PythonO(m * n * 2^l)O(m * n * 2^l)MediumBFS, Bitmasks
3619Count Islands With Total Value Divisible by KC++ PythonO(m * n)O(m + n)MediumBFS, Flood Fill
3629Minimum Jumps to Reach End via Prime TeleportationC++ Pythonprecompute: O(r)
runtime: O(nlogr)
O(r + nlogr)MediumNumber Theory, Linear Sieve of Eratosthenes, BFS
3690Split and Merge Array TransformationC++ PythonO(n^4 * n!)O(n * n!)MediumBFS
3695Maximize Alternating Sum Using SwapsC++ PythonO(n + s)O(n + s)HardBFS, Flood Fill, Quick Select
3786Total Sum of Interaction Cost in Tree GroupsC++ PythonO(nlogn)O(n)HardBFS, DFS, Small-to-Large Merging
3787Find Diameter Endpoints of a TreeC++ PythonO(n)O(n)Medium🔒BFS, Tree Diameter
3820Pythagorean Distance Nodes in a TreeC++ PythonO(n)O(n)MediumBFS
3831Median of a Binary Search Tree LevelC++ PythonO(n)O(n)Medium🔒BFS
3902Zigzag Level Sum of Binary TreeC++ PythonO(n)O(w)Hard🔒BFS
3905Multi Source Flood FillC++ PythonO(n * m)O(n * m)MediumSort, BFS, Flood Fill
3923Minimum Generations to Target PointC++ PythonO(7^6)O(7^3)MediumBFS
3991Sort Array Using Prefix ReversalsC++ PythonO(n! * n * m)O(n! * n)Medium🔒BFS, Bi-BFS
4047Minimum Operations to Make XOR of All Elements ZeroC++ PythonO(n + r * d)O(r + d)Hard🔒BFS, Bi-BFS


#TitleSolutionTimeSpaceDifficultyTagNote
3004Maximum Subtree of the Same ColorC++ PythonO(n)O(h)Medium🔒DFS
3067Count Pairs of Connectable Servers in a Weighted Tree NetworkC++ PythonO(n^2)O(n)MediumDFS, BFS
3203Find Minimum Diameter After Merging Two TreesC++ PythonO(n + m)O(n + m)Hardvariant of Tree DiameterDFS, BFS, Tree DP, Tree Diameter
3249Count the Number of Good NodesC++ PythonO(n)O(h)MediumDFS
3319K-th Largest Perfect Subtree Size in Binary TreeC++ PythonO(n)O(n)MediumDFS, Quick Select
3327Check if DFS Strings Are PalindromesC++ PythonO(n)O(n)HardDFS, Manacher's Algorithm
3331Find Subtree Sizes After ChangesC++ PythonO(n)O(n)MediumDFS, Hash Table
3367Maximize Sum of Weights after Edge RemovalsC++ PythonO(n)O(n)HardDFS, Quick Select
3590Kth Smallest Path XOR SumC++ PythonO(n * (logn)^2 + qlogn)O(n + q)HardDFS, Small-to-Large Merging, Ordered Set, Sorted List
3593Minimum Increments to Equalize Leaf PathsC++ PythonO(n)O(n)MediumDFS
3607Power Grid MaintenanceC++ PythonO(c + n + q)O(c + n)MediumDFS, Flood Fill, Sort
4015Weighted Sum of a TreeC++ PythonO(n)O(n)MediumDFS, Tree DP
4018Total Sum of Interaction Cost in Tree Groups IIC++ PythonO(nlogn)O(n)Hard🔒DFS, Small-to-Large Merging


Backtracking

#TitleSolutionTimeSpaceDifficultyTagNote
3211Generate Binary Strings Without Adjacent ZerosC++ PythonO(n * 2^n)O(n)MediumBacktracking, BFS
3437Permutations IIIC++ PythonO(n * n!)O(n)Medium🔒Backtracking, Bitmasks
3565Sequential Grid Path CoverC++ PythonO(m * n * 3^(m * n))O(m * n)Medium🔒Backtracking
3669Balanced K-Factor DecompositionC++ Pythonprecompute: O(rlogr)
runtime: O(k * (logn)^(k - 1))
O(rlogr)MediumBacktracking, Number Theory
3955Valid Binary Strings With Cost LimitC++ PythonO(n * 2^n)O(n)MediumBacktracking, Bitmasks


Dynamic Programming

#TitleSolutionTimeSpaceDifficultyTagNote
3018Maximum Number of Removal Queries That Can Be Processed IC++ PythonO(n^2)O(n^2)Hard🔒DP
3020Find the Maximum Number of Elements in SubsetC++ PythonO(n)O(n)MediumFreq Table, DP
3040Maximum Number of Operations With the Same Score IIC++ PythonO(n^2)O(n^2)MediumMemoization
3041Maximize Consecutive Elements in an Array After ModificationC++ PythonO(nlogn)O(1)HardSort, DP
3077Maximum Strength of K Disjoint SubarraysC++ PythonO(k * n)O(n)HardDP, Greedy, Kadane's Algorithm
3082Find the Sum of the Power of All SubsequencesC++ PythonO(n * k)O(k)HardDP, Combinatorics
3098Find the Sum of Subsequence PowersC++ PythonO(n^3 * k)O(n^2)HardDP, Prefix Sum, Two Pointers
3101Count Alternating SubarraysC++ PythonO(n)O(1)MediumDP
3117Minimum Sum of Values by Dividing Array[C++](./C++/minimum-sum-of-values-by-dividi

Truncated — view the full README on GitHub.

algorithm
algorithms
cpp
cpp11
data-structure
interview-practice
interview-preparation
interview-questions
leetcode
leetcode-cpp
leetcode-python
leetcode-solutions
modern-cpp
python

Project health

Overall

3.5/10

Maintained

10/10

Code review

0/10
OpenSSF Scorecard

Significant stargazers

kamyu104/LeetCode-Solutions

🏋️ Python / Modern C++ Solutions of All 4073 LeetCode Problems (Weekly Update)

C++

5,949

20,998 commits

updated Oct 12, 2026

See the code

README

LeetCode

Language  License  Update  Progress  SayThanks  Visitors

  • 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, GoogleKickStart, GoogleCodeJamIO repositories.
  • For more challenging problem solutions, you can also see my GoogleCodeJam, MetaHackerCup repositories.
  • Hope you enjoy the journey of learning data structures and algorithms.
  • Notes: "🔒" means your subscription of LeetCode premium membership is required for reading the question.

Solutions

Algorithms

JavaScript

Database

Pandas

Reference

Bit Manipulation

#TitleSolutionTimeSpaceDifficultyTagNote
3064Guess the Number Using Bitwise Questions IC++ PythonO(logn)O(1)Medium🔒Bit Manipulation
3094Guess the Number Using Bitwise Questions IIC++ PythonO(logr)O(1)Medium🔒Bit Manipulation
3125Maximum Number That Makes Result of Bitwise AND ZeroC++ PythonO(1)O(1)Medium🔒Bit Manipulation
3133Minimum Array EndC++ PythonO(logn)O(1)MediumBit Manipulation
3199Count Triplets with Even XOR Set Bits IC++ PythonO(nlogr)O(1)Easy🔒Brute Force, Bit Manipulation, Parity
3215Count Triplets with Even XOR Set Bits IIC++ PythonO(nlogr)O(1)Medium🔒Bit Manipulation, Parity
3226Number of Bit Changes to Make Two Integers EqualC++ PythonO(logn)O(1)EasyBit Manipulation
3289The Two Sneaky Numbers of DigitvilleC++ PythonO(n)O(1)EasyBit Manipulation
3304Find the K-th Character in String Game IC++ PythonO(n)O(1)EasyBitmasks
3307Find the K-th Character in String Game IIC++ PythonO(1)O(1)HardBitmasks
3314Construct the Minimum Bitwise Array IC++ PythonO(n)O(1)EasyBit Manipulation
3315Construct the Minimum Bitwise Array IIC++ PythonO(n)O(1)MediumBit Manipulation
3344Maximum Sized ArrayC++ Pythonprecompute: O(max_s^(1/5) * log(max_s))
runtime: O(log(max_s))
O(max_s^(1/5))Medium🔒Precompute, Bitmasks, Combinatorics, Binary Search
3370Smallest Number With All Set BitsC++ PythonO(1)O(1)EasyBit Manipulation
3566Partition Array into Two Equal Product SubsetsC++ PythonO(n * 2^n)O(1)MediumBitmasks
3632Subarrays with XOR at Least KC++ PythonO(nlogr)O(t)Hard🔒Bitmasks, Prefix Sum, Trie
3646Next Special Palindrome NumberC++ Pythonprecompute: O(9 * 2^9 + 16 * p + plogp)
runtime: O(logp)
O(p)HardPrecompute, Bitmasks, Sort, Binary Search
3702Longest Subsequence With Non-Zero Bitwise XORC++ PythonO(n)O(1)MediumBitmasks
3750Minimum Number of Flips to Reverse Binary StringC++ PythonO(logn)O(1)EasyBitmasks
3766Minimum Operations to Make Binary PalindromeC++ Pythonprecompute: O(sqrt(r) * logr)
runtime: O(r)
O(r)MediumPrecompute, Bitmasks, Two Pointers
3769Sort Integers by Binary ReflectionC++ PythonO(nlogr + nlogn)O(n)EasySort, Bitmasks
3782Last Remaining Integer After Alternating Deletion OperationsC++ PythonO(1)O(1)HardBitmasks, Simulation
3827Count Monobit IntegersC++ PythonO(logn)O(1)EasyBitmasks
3950Exactly One Consecutive Set Bits PairC++ PythonO(1)O(1)EasyBit Manipulation
4005Minimum Operations to Make Array Equal IIIC++ PythonO(nlogr)O(n)Hard🔒Freq Table, Bit Manipulation


Array

#TitleSolutionTimeSpaceDifficultyTagNote
3009Maximum Number of Intersections on the ChartC++ PythonO(nlogn)O(n)Hard🔒Sort, Line Sweep, Coordinate Compression
3010Divide an Array Into Subarrays With Minimum Cost IC++ PythonO(n)O(1)EasyArray, Quick Select
3015Count the Number of Houses at a Certain Distance IC++ PythonO(n)O(n)MediumMath, Prefix Sum, Difference Array
3017Count the Number of Houses at a Certain Distance IIC++ PythonO(n)O(1)HardMath, Prefix Sum, Difference Array
3026Maximum Good Subarray SumC++ PythonO(n)O(n)MediumPrefix Sum
3028Ant on the BoundaryC++ PythonO(n)O(1)EasyPrefix Sum
3030Find the Grid of Region AverageC++ PythonO(m * n)O(m * n)MediumArray
3033Modify the MatrixC++ PythonO(m * n)O(1)EasyArray
3038Maximum Number of Operations With the Same Score IC++ PythonO(n)O(1)EasyArray
3065Minimum Operations to Exceed Threshold Value IC++ PythonO(n)O(1)EasyArray
3069Distribute Elements Into Two Arrays IC++ PythonO(n)O(n)EasyArray
3070Count Submatrices with Top-Left Element and Sum Less Than kC++ PythonO(n * m)O(1)MediumArray, Prefix Sum
3071Minimum Operations to Write the Letter Y on a GridC++ PythonO(n^2)O(1)MediumArray
3079Find the Sum of Encrypted IntegersC++ PythonO(nlogr)O(1)EasyArray
3096Minimum Levels to Gain More PointsC++ PythonO(n)O(n)MediumPrefix Sum
3105Longest Strictly Increasing or Strictly Decreasing SubarrayC++ PythonO(n)O(1)EasyArray
3127Make a Square with the Same ColorC++ PythonO((n - w + 1)^2 * w^2)O(1)EasyArray
3131Find the Integer Added to Array IC++ PythonO(n)O(1)EasyArray
3142Check if Grid Satisfies ConditionsC++ PythonO(m * n)O(1)EasyArray
3147Taking Maximum Energy From the Mystic DungeonC++ PythonO(n)O(1)MediumArray
3151Special Array IC++ PythonO(n)O(1)EasyArray
3152Special Array IIC++ PythonO(n + q)O(n)MediumPrefix Sum
3153Sum of Digit Differences of All PairsC++ PythonO(nlogr)O(10 * logr)MediumPrefix Sum
3159Find Occurrences of an Element in an ArrayC++ PythonO(n + q)O(n)MediumArray
3173Bitwise OR of Adjacent ElementsC++ PythonO(n)O(1)Easy🔒Array
3187Peaks in ArrayC++ PythonO(n + qlogn)O(n)HardBIT, Fenwick Tree
3195Find the Minimum Area to Cover All Ones IC++ PythonO(n * m)O(1)MediumArray
3224Minimum Array Changes to Make Differences EqualC++ PythonO(n + k)O(k)MediumPrefix Sum, Difference Array
3279Maximum Total Area Occupied by PistonsC++ PythonO(h)O(h)Hard🔒Line Sweep, Difference Array
3285Find Indices of Stable MountainsC++ PythonO(n)O(1)EasyArray
3300Minimum Element After Replacement With Digit SumC++ PythonO(nlogr)O(1)EasyArray
3330Find the Original Typed String IC++ PythonO(n)O(1)EasyArray
3334Find the Maximum Factor Score of ArrayC++ PythonO(nlogr)O(n)MediumPrefix Sum
3349Adjacent Increasing Subarrays Detection IC++ PythonO(n)O(1)EasyArray
3350Adjacent Increasing Subarrays Detection IIC++ PythonO(n)O(1)MediumArray
3353Minimum Total OperationsC++ PythonO(n)O(1)Easy🔒Array
3354Make Array Elements Equal to ZeroC++ PythonO(n)O(n)EasyCodeChef Starters 146 - Bouncing BallPrefix Sum
3355Zero Array Transformation IC++ PythonO(n + q)O(n)MediumLine Sweep
3361Shift Distance Between Two StringsC++ PythonO(n + 26)O(26)MediumPrefix Sum
3379Transformed ArrayC++ PythonO(n)O(1)EasyArray
3380Maximum Area Rectangle With Point Constraints IC++ PythonO(nlogn)O(n)MediumSort, Brute Force, BIT, Fenwick Tree, Hash Table
3382Maximum Area Rectangle With Point Constraints IIC++ PythonO(nlogn)O(n)HardSort, BIT, Fenwick Tree, Hash Table
3386Button with Longest Push TimeC++ PythonO(n)O(1)EasyArray
3392Count Subarrays of Length Three With a ConditionC++ PythonO(n)O(1)EasyArray
3400Maximum Number of Matching Indices After Right ShiftsC++ PythonO(n^2)O(1)Medium🔒Brute Force
3417Zigzag Grid Traversal With SkipC++ PythonO(n * m)O(1)EasyArray
3423Maximum Difference Between Adjacent Elements in a Circular ArrayC++ PythonO(n)O(1)EasyArray
3427Sum of Variable Length SubarraysC++ PythonO(n)O(n)EasyDifference Array
3432Count Partitions with Even Sum DifferenceC++ PythonO(n)O(1)EasyPrefix Sum
3440Reschedule Meetings for Maximum Free Time IIC++ PythonO(n)O(1)MediumArray
3446Sort Matrix by DiagonalsC++ PythonO(n^2 * logn)O(n^2)MediumArray, Sort
3452Sum of Good NumbersC++ PythonO(n)O(1)EasyArray
3467Transform Array by ParityC++ PythonO(n)O(1)EasyArray
3502Minimum Cost to Reach Every PositionC++ PythonO(n)O(1)EasyPrefix Sum
3514Number of Unique XOR Triplets IIC++ PythonO(nlogn)O(n)MediumFast Walsh–Hadamard Transform, FWHT, Fast Subset Transform, FST, Hash Table
3531Count Covered BuildingsC++ PythonO(n)O(n)MediumArray
3537Fill a Special GridC++ PythonO(4^n)O(1)MediumDivide and Conquer, Array
3540Minimum Time to Visit All HousesC++ PythonO(n + q)O(n)Medium🔒Prefix Sum
3546Equal Sum Grid Partition IC++ PythonO(m * n)O(1)MediumArray
3548Equal Sum Grid Partition IIC++ PythonO(m * n)O(m * n)HardArray, Hash Table
3549Multiply Two PolynomialsC++ PythonO((n + m) * log(n + m))O(n + m)Hard🔒Fast Fourier Transform, FFT
3550Smallest Index With Digit Sum Equal to IndexC++ PythonO(nlogr)O(1)EasyArray
3569Maximize Count of Distinct Primes After SplitC++ PythonO(r + nlogn + qlogn)O(r + n)MediumNumber Theory, BST, Sorted List, Segment Tree
3637Trionic Array IC++ PythonO(n)O(1)EasyArray
3643Flip Square Submatrix VerticallyC++ PythonO(k^2)O(1)EasyArray
3653XOR After Range Multiplication Queries IC++ PythonO(qlogm + (q + n) * sqrt(n))O(n * sqrt(n))MediumSqrt Decomposition, Difference Array, Fast Exponentiation, Simulation
3655XOR After Range Multiplication Queries IIC++ PythonO(qlogm + (q + n) * sqrt(n))O(n * sqrt(n))HardSqrt Decomposition, Difference Array, Fast Exponentiation
3674Minimum Operations to Equalize ArrayC++ PythonO(n)O(1)EasyArray
3683Earliest Time to Finish One TaskC++ PythonO(n)O(1)EasyArray
3687Library Late Fee CalculatorC++ PythonO(n)O(1)Easy🔒Array
3688Bitwise OR of Even Numbers in an ArrayC++ PythonO(n)O(1)EasyArray
3696Maximum Distance Between Unequal Words in Array IC++ PythonO(n * l)O(1)Easy🔒Array
3700Number of ZigZag Arrays IIC++ PythonO((r - l)^3 * logn)O((r - l)^2)HardMatrix Exponentiation
3701Compute Alternating SumC++ PythonO(n)O(1)EasyArray
3706Maximum Distance Between Unequal Words in Array IIC++ PythonO(n * l)O(1)Medium🔒Array
3707Equal Score SubstringsC++ PythonO(n)O(1)EasyArray, Prefix Sum
3708Longest Fibonacci SubarrayC++ PythonO(n)O(1)MediumArray
3719Longest Balanced Subarray IC++ PythonO(nlogn)O(n)MediumBrute Force, Segment Tree, Binary Search, Prefix Sum
3721Longest Balanced Subarray IIC++ PythonO(nlogn)O(n)HardSegment Tree, Binary Search, Prefix Sum
3736Minimum Moves to Equal Array Elements IIIC++ PythonO(n)O(1)EasyArray
3737Count Subarrays With Majority Element IC++ PythonO(n)O(n)MediumFreq Table, Prefix Sum
3738Longest Non-Decreasing Subarray After Replacing at Most One ElementC++ PythonO(n)O(n)MediumArray, Prefix Sum
3739Count Subarrays With Majority Element IIC++ PythonO(n)O(n)HardFreq Table, Prefix Sum
3751Total Waviness of Numbers in Range IC++ PythonO(nlogn)O(logn)MediumBrute Force
3756Concatenate Non-Zero Digits and Multiply by Sum IIC++ PythonO(n)O(n)MediumPrefix Sum
3762Minimum Operations to Equalize SubarraysC++ PythonO((n + q) * logn)O(nlogn)HardPrefix Sum, Coordinate Compression, Persistent Segment Tree, Binary Search
3774Absolute Difference Between Maximum and Minimum K ElementsC++ PythonO(n)O(1)EasySort, Quick Select
3788Maximum Score of a SplitC++ PythonO(n)O(1)MediumPrefix Sum
3809Best Reachable TowerC++ PythonO(n)O(1)MediumArray
3814Maximum Capacity Within BudgetC++ PythonO(n + b)O(b)MediumHash Table, Prefix Sum, Sort, Mono Stack, Binary Search
3818Minimum Prefix Removal to Make Array Strictly IncreasingC++ PythonO(n)O(1)MediumArray
3819Rotate Non Negative ElementsC++ PythonO(n)O(n)MediumArray
3833Count Dominant IndicesC++ PythonO(n)O(1)EasyArray
3861Minimum Capacity BoxC++ PythonO(n)O(1)EasyArray
3862Find the Smallest Balanced IndexC++ PythonO(n)O(1)MediumPrefix Sum
3865Reverse K SubarraysC++ PythonO(n)O(1)Medium🔒Array
3880Minimum Absolute Difference Between Two ValuesC++ PythonO(n)O(1)EasyArray
3886Sum of Sortable IntegersC++ PythonO(nlog(logn))O(n)HardPrefix Sum, Number Theory
3898Find the Degree of Each VertexC++ PythonO(n * m)O(1)EasyArray
3903Smallest Stable Index IC++ PythonO(n)O(n)EasyPrefix Sum
3904Smallest Stable Index IIC++ PythonO(n)O(n)MediumPrefix Sum
3907Count Smaller Elements With Opposite ParityC++ PythonO(nlogn)O(n)Medium🔒Sort, Coordinate Compression, BIT, Fenwick Tree
3909Compare Sums of Bitonic PartsC++ PythonO(n)O(1)MediumArray
3912Valid Elements in an ArrayC++ PythonO(n)O(n)MediumPrefix Sum
3915Maximum Sum of Alternating Subsequence With Distance at Least KC++ PythonO(nlogn)O(n)HardSort, Coordinate Compression, BIT, Fenwick Tree, Sliding Window, DP
3918Sum of Primes Between Number and Its ReverseC++ Pythonprecompute: O(r)
runtime: O(1)
O(r)MediumNumber Theory, Linear Sieve of Eratosthenes, Prefix Sum
3925Concatenate Array With ReverseC++ PythonO(n)O(1)EasyArray
3933Largest Local Values in a Matrix IIC++ PythonO(n * m * logn * logm)O(n * m * logn * logm)MediumRMQ, 2D Sparse Table
3936Minimum Swaps to Move Zeros to EndC++ PythonO(n)O(1)EasyArray
3938Maximum Path Intersection Sum in a GridC++ PythonO(n * m)O(1)MediumArray, Kadane's Algorithm
3940Limit Occurrences in Sorted ArrayC++ PythonO(n)O(1)EasyArray, Inplace
3942Minimum Operations to Sort a PermutationC++ PythonO(n)O(1)MediumArray
3943Number of Pairs After IncrementC++ PythonO(n + m + q * sqrt(m * n))O(n + m)HardFreq Table, Sqrt Decomposition
3951Minimum Energy to Maintain BrightnessC++ PythonO(nlogn)O(1)MediumSort, Line Sweep
3951Minimum Energy to Maintain BrightnessC++ PythonO(nlogn)O(1)MediumSort, Line Sweep
3963Create Grid With Exactly One PathC++ PythonO(m * n)O(1)EasyArray
3978Unique Middle ElementC++ PythonO(n)O(1)EasyArray
3979Maximum Valid Pair SumC++ PythonO(n)O(n)MediumPrefix Sum
3982Sum of Integers with Maximum Digit RangeC++ PythonO(nlogr)O(1)EasyArray
3985Palindromic Subarray SumC++ PythonO(n)O(n)HardPrefix Sum, Manacher's Algorithm
3998Transform Binary String Using Subsequence SortC++ PythonO(n * m)O(n)HardPrefix Sum
4006Count Valid PrefixesC++ PythonO(n)O(1)EasyPrefix Sum
4010Maximize Pair Strength Using GCDC++ PythonO(n^2 * logr)O(1)EasyBrute Force, Sort, Pruning
4011Count Subarrays With Even Odd Ratio IC++ PythonO(nlogn)O(n)MediumPrefix Sum, Sort, Coordinate Compression, BIT, Fenwick Tree, Brute Force
4012Count of Unfinished Tasks After Each ShiftC++ PythonO(n + mlogn)O(n)MediumPrefix Sum, Binary Search
4013Count Subarrays With Even Odd Ratio IIC++ PythonO(nlogn)O(n)HardPrefix Sum, Sort, Coordinate Compression, BIT, Fenwick Tree
4017Peaks in Array IIC++ PythonO(nlogn + qlogn)O(n)HardBIT, Fenwick Tree
4020Elevator Requests IC++ PythonO(m)O(1)EasyArray
4021Minimum Operations to Make a Rotated Palindrome IC++ PythonO(nlogn)O(n)MediumBrute Force, NTT
4024Nearest Available DroneC++ PythonO(n)O(1)EasyArray
4028Minimum Operations to Make a Rotated Palindrome IIC++ PythonO(nlogn)O(n)Hard🔒NTT
4051Count Subarrays with Distant SumsC++ PythonO(nlogn)O(n)HardPrefix Sum, Sorted List, Ordered Set, BIT, Fenwick Tree
4052Cyclically Shift Rows and ColumnsC++ PythonO(n^2)O(1)EasyArray, Inplace
4056Number of Intersecting Interval Pairs IC++ PythonO(nlogn)O(n)EasyBrute Force, Sort, Line Sweep
4057Number of Intersecting Interval Pairs IIC++ PythonO(nlogn)O(n)MediumSort, Line Sweep
4058Maximum Pulse Value After One Subarray RotationC++ PythonO(n)O(1)MediumPrefix Sum, Hash Table
4062Transform Array Using Pair OperationsC++ PythonO(n)O(1)MediumArray
4063Longest Subarray Divisible by K with At Most One Negation IC++ PythonO(n + k^2)O(k)MediumPrefix Sum, Hash Table, Brute Force
4064Longest Subarray Divisible by K with At Most One Negation IIC++ PythonO(n + k^2)O(k)HardPrefix Sum, Hash Table
4073Count Good StringsC++ PythonO(logr)O(1)HardMatrix Fast Exponentiation


String

#TitleSolutionTimeSpaceDifficultyTagNote
3019Number of Changing KeysC++ PythonO(n)O(1)EasyString
3023Find Pattern in Infinite Stream IC++ PythonO(p + n)O(p)Medium🔒String, KMP Algorithm
3029Minimum Time to Revert Word to Initial State IC++ PythonO(n)O(n)MediumString, Z-Function, Brute Force
3031Minimum Time to Revert Word to Initial State IIC++ PythonO(n)O(n)HardString, Z-Function
3034Number of Subarrays That Match a Pattern IC++ PythonO(n)O(m)MediumBrute Force, String, KMP Algorithm
3036Number of Subarrays That Match a Pattern IIC++ PythonO(n)O(m)HardString, KMP Algorithm
3037Find Pattern in Infinite Stream IIC++ PythonO(p + n)O(p)Hard🔒String, KMP Algorithm
3042Count Prefix and Suffix Pairs IC++ PythonO(n * l)O(t)EasyTrie, Brute Force
3043Find the Length of the Longest Common PrefixC++ PythonO((n + m) * l)O(t)MediumTrie, Hash Table
3045Count Prefix and Suffix Pairs IIC++ PythonO(n * l)O(t)HardTrie
3076Shortest Uncommon Substring in an ArrayC++ PythonO(n * l^2)O(t)MediumTrie
3093Longest Common Suffix QueriesC++ PythonO((n + q) * l)O(t)HardTrie
3110Score of a StringC++ PythonO(n)O(1)EasyString
3136Valid WordC++ PythonO(n)O(1)EasyString
3163String Compression IIIC++ PythonO(n)O(1)MediumString
3210Find the Encrypted StringC++ PythonO(n)O(1)MediumString
3271Hash Divided StringC++ PythonO(n)O(1)MediumString
3280Convert Date to BinaryC++ PythonO(1)O(1)EasyString
3303Find the Occurrence of First Almost Equal SubstringC++ PythonO(n + m)O(n + m)HardZ-Function
3324Find the Sequence of Strings Appeared on the ScreenC++ PythonO(n^2)O(1)MediumString
3340Check Balanced StringC++ PythonO(n)O(1)EasyString
3407Substring Matching PatternC++ PythonO(n + m)O(m)EasyString, KMP Algorithm
3455Shortest Matching SubstringC++ PythonO(n + m)O(n + m)HardString, KMP Algorithm, Two Pointers
3456Find Special Substring of Length KC++ PythonO(n)O(1)EasyString
3491Phone Number PrefixC++ PythonO(l * nlogn)O(1)Easy🔒Trie, Sort
3498Reverse Degree of a StringC++ PythonO(n)O(1)EasyString
3529Count Cells in Overlapping Horizontal and Vertical SubstringsC++ PythonO(n * m)O(n * m)MediumZ-Function
3571Find the Shortest Superstring IIC++ PythonO(n + m)O(n + m)Easy🔒KMP Algorithm
3582Generate Tag for Video CaptionC++ PythonO(n)O(1)EasyString
3598Longest Common Prefix Between Adjacent Strings After RemovalsC++ PythonO(n * l)O(n)MediumLCP, Prefix Sum
3606Coupon Code ValidatorC++ PythonO(l * nlogn)O(n * l)EasyHash Table, Sort
3744Find Kth Character in Expanded StringC++ PythonO(n)O(1)Medium🔒String
3746Minimum String Length After Balanced RemovalsC++ PythonO(n)O(1)MediumString
3748Count Stable SubarraysC++ PythonO(n + q)O(n)HardPrefix Sum
3758Convert Number Words to DigitsC++ PythonO(n)O(1)Medium🔒String
3775Reverse Words With Same Vowel CountC++ PythonO(n)O(1)MediumString, Inplace
3777Minimum Deletions to Make Alternating SubstringC++ PythonO((n + q) * logn)O(n)HardBIT, Fenwick Tree
3794Reverse String PrefixC++ PythonO(n)O(1)EasyString
3813Vowel-Consonant ScoreC++ PythonO(n)O(1)EasyString
3823Reverse Letters Then Special Characters in a StringC++ PythonO(n)O(1)EasyString
3838Weighted Word MappingC++ PythonO(n * l)O(1)EasyString
3856Trim Trailing VowelsC++ PythonO(n)O(1)EasyString
3860Unique Email GroupsC++ PythonO(n * l)O(n * l)Medium🔒String, Hash Table
3884First Matching Character From Both EndsC++ PythonO(n)O(1)MediumString
3931Check Adjacent Digit DifferencesC++ PythonO(n)O(1)EasyString
3941Password StrengthC++ PythonO(n)O(1)MediumString, Hash Table
3986Number of Elapsed Seconds Between Two TimesC++ PythonO(1)O(1)EasyString
3999Minimum Number of String Groups Through TransformationsC++ PythonO(n * l)O(n * l)HardHash Table, String
4030Check ASCII PalindromicC++ PythonO(n)O(1)EasyString, Bitmasks
4043Count Rotations With Exactly K Equal Adjacent PairsC++ PythonO(n)O(1)EasyString
4070Minimum Rotations to Dial a Number IC++ PythonO(n)O(1)EasyString
4071Minimum Rotations to Dial a Number IIC++ PythonO(n)O(1)MediumString


Linked List

#TitleSolutionTimeSpaceDifficultyTagNote
3062Winner of the Linked List GameC++ PythonO(n)O(1)Easy🔒Linked List
3063Linked List FrequencyC++ PythonO(n)O(1)Medium🔒Linked List
3217Delete Nodes From Linked List Present in ArrayC++ PythonO(n)O(m)MediumHash Table, Linked List
3263Convert Doubly Linked List to Array IC++ PythonO(n)O(1)Easy🔒Linked List
3294Convert Doubly Linked List to Array IIC++ PythonO(n)O(1)Medium🔒Linked List


Stack

#TitleSolutionTimeSpaceDifficultyTagNote
3113Find the Number of Subarrays Where Boundary Elements Are MaximumC++ PythonO(n)O(n)HardMono Stack, Combinatorics
3174Clear DigitsC++ PythonO(n)O(1)EasyStack, Two Pointers
3676Count Bowl SubarraysC++ PythonO(n)O(n)MediumMono Stack
3703Remove K-Balanced SubstringsC++ PythonO(n)O(n)MediumStack
3749Evaluate Valid ExpressionsC++ PythonO(n)O(n)Hard🔒Stack
3834Merge Adjacent Equal ElementsC++ PythonO(n)O(1)MediumStack, Simulation
3878Count Good SubarraysC++ PythonO(n)O(n)HardCombinatorics, Mono Stack
4054Count Shadow Pairs IC++ PythonO(n)O(n)MediumFreq Table, Mono Stack
4055Count Shadow Pairs IIC++ PythonO(nlogn)O(n)HardCoordinate Compression, Merge Sort, Mono Stack


Queue

#TitleSolutionTimeSpaceDifficultyTagNote


Binary Heap

#TitleSolutionTimeSpaceDifficultyTagNote
3066Minimum Operations to Exceed Threshold Value IIC++ PythonO(nlogn)O(n)MediumSimulation, Heap
3080Mark Elements on Array by Performing QueriesC++ PythonO(q + nlogn)O(n)MediumHash Table, Heap
3092Most Frequent IDsC++ PythonO(nlogn)O(n)MediumHeap, BST, Sorted List
3256Maximum Value Sum by Placing Three Rooks IC++ PythonO(m * n)O(m + n)HardHeap, Brute Force
3257Maximum Value Sum by Placing Three Rooks IIC++ PythonO(m * n)O(m + n)HardHeap, Brute Force
3275K-th Nearest Obstacle QueriesC++ PythonO(qlogk)O(k)MediumHeap
3684Maximize Sum of At Most K Distinct ElementsC++ PythonO(nlogk)O(k)EasyHeap, Sort
3691Maximum Total Subarray Value IIC++ PythonO((n + k) * logn)O(n)HardHeap, Sort, Two Pointers, RMQ, Sparse Table, Segment Tree
3781Maximum Score After Binary SwapsC++ PythonO(nlogn)O(n)MediumHeap
3962Maximum Subarray Sum After at Most K SwapsC++ PythonO(n^2 * logk)O(n)HardPrefix Sum, Heap, DP
4004Minimum Moves to Balance Circular Array IIC++ PythonO(n^2 * logn)O(n)Hard🔒, variant of Codeforces Round #13 CL1 Isotonic Regression, Heap, Greedy, Graph, Min-Cost Max-Flow, MCMF, Successive Shortest Path, SSP, Dijkstra's Algorithm, Johnson Potential


Tree

#TitleSolutionTimeSpaceDifficultyTagNote
3109Find the Index of PermutationC++ PythonO(nlogn)O(n)Medium🔒, variant of Count of Smaller Numbers After SelfBIT, Fenwick Tree, Combinatorics
3515Shortest Path in a Weighted TreeC++ PythonO(nlogn)O(n)HardBIT, Fenwick Tree, DFS
3553Minimum Weighted Subgraph With the Required Paths IIC++ PythonO(n + q)O(n + q)HardTree, DFS, Tarjan's Offline LCA Algorithm
3558Number of Ways to Assign Edge Weights IC++ PythonO(n)O(n)MediumTree, BFS, Combinatorics
3559Number of Ways to Assign Edge Weights IIC++ PythonO(n + q)O(n + q)MediumTree, DFS, Tarjan's Offline LCA Algorithm, Combinatorics
3585Find Weighted Median Node in TreeC++ PythonO(n + qlogh)O(n + q)HardTree, DFS, Tarjan's Offline LCA Algorithm, Binary Search, Prefix Sum
3715Sum of Perfect Square AncestorsC++ Pythonprecompute: O(r)
runtime: O(nlogx)
O(r + n)HardTree, Number Theory, Linear Sieve of Eratosthenes, Freq Table, DFS
3841Palindromic Path Queries in a TreeC++ PythonO((n + q) * logn)O(n)HardDFS, HLD, Heavy-Light Decomposition, LCA, Binary Lifting, BIT, Fenwick Tree
3879Maximum Distinct Path Sum in a Binary TreeC++ PythonO(n^2)O(n)MediumDFS, BFS
3973Distinct Gate Paths to LCAC++ PythonO(nlogn + qlogn)O(nlogn)Hard🔒DFS, LCA, Binary Lifting
3997Count Dominant Nodes in a Binary TreeC++ PythonO(n)O(h)MediumDFS


Hash Table

#TitleSolutionTimeSpaceDifficultyTagNote
3005Count Elements With Maximum FrequencyC++ PythonO(n)O(n)EasyFreq Table
3039Apply Operations to Make String EmptyC++ PythonO(n)O(1)MediumFreq Table
3044Most Frequent PrimeC++ Pythonprecompute: O(10^MAX_N_M)
runtime: O(n * m * (n + m))
O(10^MAX_N_M + n * m * (n + m))MediumNumber Theory, Linear Sieve of Eratosthenes, Freq Table
3046Split the ArrayC++ PythonO(n)O(n)EasyFreq Table
3078Match Alphanumerical Pattern in Matrix IC++ PythonO(n * m * r * c)O(1)Medium🔒Brute Force, Hash Table
3083Existence of a Substring in a String and Its ReverseC++ PythonO(n)O(min(n, 26^2))EasyHash Table
3120Count the Number of Special Characters IC++ PythonO(n + 26)O(26)EasyHash Table
3121Count the Number of Special Characters IIC++ PythonO(n + 26)O(26)MediumHash Table
3137Minimum Number of Operations to Make Word K-PeriodicC++ PythonO(n)O(n)MediumFreq Table
3138Minimum Length of Anagram ConcatenationC++ PythonO(sqrt(n) * n + 26 * nlogn)O(26)MediumNumber Theory, Freq Table
3143Maximum Points Inside the SquareC++ PythonO(n + 26)O(26)MediumHash Table
3146Permutation Difference between Two StringsC++ PythonO(n + 26)O(26)EasyHash Table
3158Find the XOR of Numbers Which Appear TwiceC++ PythonO(n)O(n)EasyHash Table
3160Find the Number of Distinct Colors Among the BallsC++ PythonO(q)O(q)MediumFreq Table
3167Better Compression of StringC++ PythonO(n + 26)O(26)Medium🔒Freq Table, Counting Sort
3184Count Pairs That Form a Complete Day IC++ PythonO(n + 24)O(24)EasyFreq Table
3185Count Pairs That Form a Complete Day IIC++ PythonO(n + 24)O(24)MediumFreq Table
3223Minimum Length of String After OperationsC++ PythonO(n + 26)O(26)MediumFreq Table
3237Alt and Tab SimulationC++ PythonO(n)O(n)Medium🔒Hash Table
3238Find the Number of Winning PlayersC++ PythonO(p)O(min(n * c, p)EasyFreq Table
3245Alternating Groups IIIC++ PythonO(nlogn + qlogn)O(n)HardBST, Sorted List, Freq Table, BIT, Fenwick Tree
3295Report Spam MessageC++ PythonO(n + m)O(m)MediumHash Table
3365Rearrange K Substrings to Form Target StringC++ PythonO(n)O(n)MediumFreq Table
3371Identify the Largest Outlier in an ArrayC++ PythonO(n)O(n)MediumFreq Table
3396Minimum Number of Operations to Make Elements in Array DistinctC++ PythonO(n + r)O(r)EasyFreq Table
3404Count Special SubsequencesC++ PythonO(n^2)O(n^2)MediumFreq Table, Number Theory
3438Find Valid Pair of Adjacent Digits in StringC++ PythonO(n)O(1)EasyFreq Table
3442Maximum Difference Between Even and Odd Frequency IC++ PythonO(n + 26)O(26)EasyFreq Table
3450Maximum Students on a Single BenchC++ PythonO(n)O(n)Easy🔒Hash Table, Unordered Set
3471Find the Largest Almost Missing IntegerC++ PythonO(n)O(n)EasyFreq Table
3487Maximum Unique Subarray Sum After DeletionC++ PythonO(n)O(n)EasyHash Table
3488Closest Equal Element QueriesC++ PythonO(n)O(n)MediumHash Table
3527Find the Most Common ResponseC++ PythonO(n * l)O(n * l)MediumHash Table, Freq Table
3541Find Most Frequent Vowel and ConsonantC++ PythonO(n + 26)O(26)EasyFreq Table
3572Maximize Y‑Sum by Picking a Triplet of Distinct X‑ValuesC++ PythonO(n)O(n)MediumHash Table, Quick Select
3581Count Odd Letters from NumberC++ PythonO(logn)O(26)Easy🔒Freq Table
3591Check if Any Element Has Prime FrequencyC++ Pythonprecompute: O(MAX_N)
runtime: O(n)
O(MAX_N)EasyFreq Table, Number Theory, Linear Sieve of Eratosthenes
3636Threshold Majority QueriesC++ PythonO(nlogn + qlogq + (n + q) * sqrt(n) * logn)O(q + n)HardSort, Coordinate Compression, Sqrt Decomposition, Mo's Algorithm, Freq Table, Sorted List, BST
3662Filter Characters by FrequencyC++ PythonO(n + 26)O(26)Easy🔒Freq Table
3663Find The Least Frequent DigitC++ PythonO(logn + 10)O(10)EasyFreq Table
3668Restore Finishing OrderC++ PythonO(n + min(8, n))O(min(8, n))EasyHash Table
3678Smallest Absent Positive Greater Than AverageC++ PythonO(n)O(n)EasyHash Table
3682Minimum Index Sum of Common ElementsC++ PythonO(n + m)O(n)Medium🔒Hash Table
3692Majority Frequency CharactersC++ PythonO(n + 26)O(26)EasyFreq Table
3694Distinct Points Reachable After Substring RemovalC++ PythonO(n)O(n)MediumHash Table
3712Sum of Elements With Frequency Divisible by KC++ PythonO(n)O(n)EasyFreq Table
3713Longest Balanced Substring IC++ PythonO(n * (a + n))O(a)MediumFreq Table
3714Longest Balanced Substring IIC++ PythonO(n)O(n)MediumHash Table, Prefix Sum
3718Smallest Missing Multiple of KC++ PythonO(n)O(n)EasyHash Table
3728Stable Subarrays With Equal Boundary and Interior SumC++ PythonO(n)O(n)MediumFreq Table, Prefix Sum
3729Count Distinct Subarrays Divisible by K in Sorted ArrayC++ PythonO(n)O(min(n, k))HardFreq Table, Prefix Sum
3755Find Maximum Balanced XOR Subarray LengthC++ PythonO(n)O(n)MediumHash Table, Prefix Sum
3760Maximum Substrings With Distinct StartC++ PythonO(n + 26)O(26)MediumHash Table
3761Minimum Absolute Distance Between Mirror PairsC++ PythonO(nlogr)O(n)MediumHash Table
3773Maximum Number of Equal Length RunsC++ PythonO(n)O(sqrt(n))Medium🔒Freq Table
3779Minimum Number of Operations to Have Distinct ElementsC++ PythonO(n)O(n)MediumHash Table
3784Minimum Deletion Cost to Make All Characters EqualC++ PythonO(n + 26)O(26)MediumFreq Table
3803Count Residue PrefixesC++ PythonO(n + 26)O(26)EasyHash Table
3804Number of Centered SubarraysC++ PythonO(n^2)O(n)MediumHash Table
3805Count Caesar Cipher PairsC++ PythonO(n * m)O(n * m)MediumFreq Table
3810Minimum Operations to Reach Target ArrayC++ PythonO(n)O(n)MediumHash Table
3837Delayed Count of Equal ElementsC++ PythonO(n)O(n)Medium🔒Freq Table
3839Number of Prefix Connected GroupsC++ PythonO(n * k)O(n * k)MediumFreq Table
3842Toggle Light BulbsC++ PythonO(n + r)O(r)EasyFreq Table, Sort
3843First Element with Unique FrequencyC++ PythonO(n)O(n)MediumFreq Table
3846Total Distance to Type a String Using One FingerC++ PythonO(n)O(n)Medium🔒Hash Table
3848Check Digitorial PermutationC++ PythonO(logn + 10)O(10)MediumFreq Table
3852Smallest Pair With Different FrequenciesC++ PythonO(n)O(n)EasyFreq Table
3866First Unique Even ElementC++ PythonO(n)O(n)EasyFreq Table
3889Mirror Frequency DistanceC++ PythonO(n + 36)O(36)MediumFreq Table
3890Integers With Multiple Sum of Two CubesC++ PythonO(n^(2/3) * logn)O(n^(2/3))MediumBrute Force, Freq Table, Sort
3900Longest Balanced Substring After One SwapC++ PythonO(n)O(n)Mediumvariant of Contiguous ArrayHash Table
3901Good Subsequence QueriesC++ Pythonprecompute: O(rlog(logr))
runtime: O(r + n + q)
O(rlog(logr) + n)MediumNumber Theory, Freq Table
3913Sort Vowels by FrequencyC++ PythonO(n)O(1)MediumFreq Table, Sort
3917Count Indices With Opposite ParityC++ PythonO(n)O(1)EasyFreq Table
3921Score ValidatorC++ PythonO(n)O(1)EasyFreq Table
3926Count Valid Word OccurrencesC++ PythonO(n)O(n)MediumFreq Table
3945Digit Frequency ScoreC++ PythonO(logn)O(1)EasyFreq Table
3960Frequency Balance SubarrayC++ PythonO(n^2)O(n)MediumSort, Coordinate Compression, Freq Table
4007Widest Possible FenceC++ PythonO(n + c^2)O(c^2)MediumFreq Table
4038Count Integers Appearing in a Single BlockC++ PythonO(n)O(n)EasyFreq Table
4048Count Values With Equally Spaced Occurrences IC++ PythonO(n)O(n)EasyHash Table
4049Count Values With Equally Spaced Occurrences IIC++ PythonO(n)O(n)MediumHash Table
4066Maximum Equal Adjacent Pairs After at Most One ReplacementC++ PythonO(n)O(n)MediumFreq Table


Math

#TitleSolutionTimeSpaceDifficultyTagNote
3001Minimum Moves to Capture The QueenC++ PythonO(1)O(1)MediumMath
3007Maximum Number That Sum of the Prices Is Less Than or Equal to KC++ PythonO(max(logk, x) * log((logk) / x))O((logk) / x)MediumBit Manipulation, Binary Search, Combinatorics
3021Alice and Bob Playing Flower GameC++ PythonO(1)O(1)MediumCombinatorics
3024Type of Triangle IIC++ PythonO(1)O(1)EasyMath
3032Count Numbers With Unique Digits IIC++ PythonO(logb)O(1)Easy🔒, variant of Count Numbers With Unique DigitsBrute Force, Hash Table, Bitmasks, Combinatorics
3047Find the Largest Area of Square Inside Two RectanglesC++ PythonO(n^2)O(1)MeidumBrute Force, Math
3084Count Substrings Starting and Ending with Given CharacterC++ PythonO(n)O(1)MeidumCombinatorics
3091Apply Operations to Make Sum of Array Greater Than or Equal to kC++ PythonO(logn)O(1)MeidumCodeforces Round #674 CMath
3099Harshad NumberC++ PythonO(logx)O(1)EasyMath
3102Minimize Manhattan DistancesC++ PythonO(n)O(1)HardMath
3115Maximum Prime DifferenceC++ PythonO(r + n)O(r)MediumArray, Number Theory, Linear Sieve of Eratosthenes
3128Right TrianglesC++ PythonO(n * m)O(min(n, m))MediumArray, Combinatorics, Freq Table
3154Find Number of Ways to Reach the K-th StairC++ PythonO(logk)O(logk)HardCombinatorics
3155Maximum Number of Upgradable ServersC++ PythonO(n)O(1)Medium🔒Math
3162Find the Number of Good Pairs IC++ PythonO(rlogr + n + m)O(r)EasyBrute Force, Number Theory, Freq Table
3164Find the Number of Good Pairs IIC++ PythonO(rlogr + n + m)O(r)MediumNumber Theory, Freq Table
3178Find the Child Who Has the Ball After K SecondsC++ PythonO(1)O(1)EasyMath
3179Find the N-th Value After K SecondsC++ PythonO(n + k)O(n + k)MediumPrefix Sum, Combinatorics
3183The Number of Ways to Make the SumC++ PythonO(1)O(1)Medium🔒Math, DP
3190Find Minimum Operations to Make All Elements Divisible by ThreeC++ PythonO(n)O(1)EasyMath
3200Maximum Height of a TriangleC++ PythonO(logn)O(1)EasySimulation, Math
3222Find the Winning Player in Coin GameC++ PythonO(1)O(1)EasyMath
3227Vowels Game in a StringC++ PythonO(n)O(1)MediumMath
3232Find if Digit Game Can Be WonC++ PythonO(n)O(1)EasyBrute Force, Game Theory
3247Number of Subsequences with Odd SumC++ PythonO(n)O(1)Medium🔒Combinatorics, Fast Exponentiation, DP
3250Find the Count of Monotonic Pairs IC++ PythonO(n + r)O(n + r)HardCombinatorics, Stars and Bars, DP, Prefix Sum
3251Find the Count of Monotonic Pairs IIC++ PythonO(n + r)O(n + r)HardCombinatorics, Stars and Bars, DP, Prefix Sum
3270Find the Key of the NumbersC++ PythonO(d)O(1)EasyMath
3272Find the Count of Good IntegersC++ PythonO(n + 10 * 10^((n + 1)/2))O(n + 10 * (10 * nHr(10, n/2)))HardCombinatorics, Freq Table
3274Check if Two Chessboard Squares Have the Same ColorC++ PythonO(1)O(1)EasyMath, Parity
3284Sum of Consecutive SubarraysC++ PythonO(n)O(1)Medium🔒Combinatorics
3299Sum of Consecutive SubsequencesC++ PythonO(n)O(n)Hard🔒Combinatorics, Prefix Sum, DP
3312Sorted GCD Pair QueriesC++ PythonO(rlogr + qlogr)O(r)HardNumber Theory, Freq Table, Prefix Sum, Binary Search
3317Find the Number of Possible Ways for an EventC++ Pythonprecompute: 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))HardDP, Combinatorics
3326Minimum Division Operations to Make Array Non DecreasingC++ Pythonprecompute: O(r)
runtime: O(n)
O(r)MediumGreedy, Number Theory, Linear Sieve of Eratosthenes
3339Find the Number of K-Even ArraysC++ PythonO(n)O(n)Medium🔒DP, Stars and Bars, Combinatorics
3345Smallest Divisible Digit Product IC++ PythonO(logn)O(1)EasyBrute Force
3348Smallest Divisible Digit Product IIC++ PythonO(n + logt)O(1)HardFreq Table, Greedy, Prefix Sum, Number Theory
3360Stone Removal GameC++ PythonO(1)O(1)EasyMath
3395Subsequences with a Unique Middle Mode IC++ PythonO(n)O(n)HardFreq Table, Prefix Sum, Combinatorics
3405Count the Number of Arrays with K Matching Adjacent ElementsC++ PythonO(n + logm)O(n)HardCombinatorics, Fast Exponentiation
3411Maximum Subarray With Equal ProductsC++ Pythonprecompute: O(r * log(logr))
runtime: O(n * log(logr))
O(r * log(logr))EasyNumber Theory, Linear Sieve of Eratosthenes, Hash Table
3416Subsequences with a Unique Middle Mode IIC++ PythonO(n)O(n)Hard🔒Freq Table, Prefix Sum, Combinatorics
3426Manhattan Distances of All Arrangements of PiecesC++ Pythonprecompute: O(max(m * n))
runtime: O(1)
O(max(m * n))HardCombinatorics
3428Maximum and Minimum Sums of at Most Size K SubsequencesC++ PythonO(nlogn)O(n)MediumSort, Combinatorics, Two Pointers, Sliding Window
3447Assign Elements to Groups with ConstraintsC++ PythonO(m + r * logn)O(r)MediumHash Table, Number Theory
3448Count Substrings Divisible By Last DigitC++ PythonO(d * n)O(d)HardDP, Case Works, Math, Freq Table
3461Check If Digits Are Equal in String After Operations IC++ PythonO(nlogn)O(1)EasyFast Exponentiation, Luca's Theorem, Simulation
3463Check If Digits Are Equal in String After Operations IIC++ PythonO(nlogn)O(1)HardFast Exponentiation, Lucas's Theorem
3470Permutations IVC++ PythonO(n^2)O(n)HardCombinatorics
3483Unique 3-Digit Even NumbersC++ PythonO(n)O(1)EasyFreq Table, Combinatorics
3492Maximum Containers on a ShipC++ PythonO(1)O(1)EasyMath
3512Minimum Operations to Make Array Sum Divisible by KC++ PythonO(n)O(1)EasyMath
3513Number of Unique XOR Triplets IC++ PythonO(logn)O(1)MediumBit Manipulation, Math
3516Find Closest PersonC++ PythonO(1)O(1)EasyMath
3519Count Numbers with Non-Decreasing DigitsC++ PythonO(n^2)O(n)HardMath, Stars and Bars, Combinatorics
3556Sum of Largest Prime SubstringsC++ PythonO(n^2 * sqrt(r))O(n^2)MediumNumber Theory, Quick Select
3560Find Minimum Log Transportation CostC++ PythonO(1)O(1)EasyMath
3577Count the Number of Computer Unlocking PermutationsC++ PythonO(n)O(1)MediumCombinatorics
3588Find Maximum Area of a TriangleC++ PythonO(n)O(n)MediumMath, Hash Table
3596Minimum Cost Path with Alternating Directions IC++ PythonO(1)O(1)Medium🔒Math
3602Hexadecimal and Hexatrigesimal ConversionC++ PythonO(logn)O(1)EasyMath
3618Split Array by Prime IndicesC++ Pythonprecompute: O(max_n)
runtime: O(n)
O(max_n)MediumNumber Theory, Linear Sieve of Eratosthenes
3621Number of Integers With Popcount-Depth Equal to K IC++ Pythonprecompute: O((logr)^2)
runtime: O((logn)^2)
O((logr)^2)HardCombinatorics
3622Check Divisibility by Digit Sum and ProductC++ PythonO(logn)O(1)EasyMath
3623Count Number of Trapezoids IC++ PythonO(n)O(n)MediumFreq Table, Combinatorics
3624Number of Integers With Popcount-Depth Equal to K IIC++ Pythonprecompute: O((logr) * log(logr))
runtime: O(nlogr + max_k * n + nlogn + qlogn)
O(logr + max_k * n)HardBIT, Fenwick Tree
3625Count Number of Trapezoids IIC++ PythonO(n^2 * logr)O(n^2)HardFreq Table, Combinatorics
3648Minimum Sensors to Cover GridC++ PythonO(1)O(1)MediumMath
3658GCD of Odd and Even SumsC++ PythonO(1)O(1)EasyMath
3659Partition Array Into K-Distinct GroupsC++ PythonO(n)O(n)MediumMath, Freq Table
3664Two-Letter Card GameC++ PythonO(n + 26)O(26)MediumMath, Freq Table
3666Minimum Operations to Equalize Binary StringC++ PythonO(n)O(1)HardMath
3671Sum of Beautiful SubsequencesC++ Pythonprecompute: O(rlogr)
runtime: O(nlogr * (log(nlogr) + logn))
O(rlogr)HardNumber Theory, BIT, Fenwick Tree
3677Count Binary Palindromic NumbersC++ PythonO(logn)O(1)HardBitmasks, Combinatorics
3697Compute Decimal RepresentationC++ PythonO(logn)O(1)EasyMath
3726Remove Zeros in Decimal RepresentationC++ PythonO(logn)O(1)EasyMath, String
3731Find Missing ElementsC++ PythonO(n + r)O(n)EasyHash Table
3745Maximize Expression of Three ElementsC++ PythonO(n)O(1)EasyMath
3747Count Distinct Integers After Removing ZerosC++ PythonO(logn)O(1)MediumCombinatorics
3754Concatenate Non-Zero Digits and Multiply by Sum IC++ PythonO(logn)O(1)EasyMath
3765Complete Prime NumberC++ PythonO(logn * sqrt(n))O(1)MediumPrefix Sum, Number Theory
3770Largest Prime from Consecutive Prime SumC++ Pythonprecompute: O(r)
runtime: O(logp)
O(sqrt(r))MediumPrecompute, Number Theory, Linear Sieve of Eratosthenes, Binary Search
3783Mirror Distance of an IntegerC++ PythonO(logn)O(1)EasyMath
3789Minimum Cost to Acquire Required ItemsC++ PythonO(1)O(1)MediumMath
3790Smallest All-Ones MultipleC++ PythonO(k)O(1)Mediumduplicate of Smallest Integer Divisible by KMath
3798Largest Even NumberC++ PythonO(n)O(1)EasyMath
3800Minimum Cost to Make Two Binary Strings EqualC++ PythonO(n)O(1)MediumMath
3817Good Indices in a Digit StringC++ PythonO(n)O(1)Medium🔒Math, Sliding Window
3821Find Nth Smallest Integer With K One BitsC++ Pythonctor: O(r^2)
runtime: O(r)
O(r^2)HardDP, Combinatorics
3855Sum of K-Digit Numbers in a RangeC++ PythonO(logr)O(1)HardMath
3857Minimum Cost to Split into OnesC++ PythonO(1)O(1)MediumCombinatorics
3870Count Commas in RangeC++ PythonO(logn)O(1)EasyMath
3871Count Commas in Range IIC++ PythonO(logn)O(1)MediumMath
3881Direction Assignments with Exactly K Visible PeopleC++ PythonO(n)O(n)MediumCombinatorics
3895Count Digit AppearancesC++ PythonO(nlogr)O(1)MediumMath
3896Count Digit AppearancesC++ Pythonprecompute: O(r), runtime: O(nlogn)O(r)MediumNumber Theory, Linear Sieve of Eratosthenes, Prime Gap, Binary Search
3899Angles of a TriangleC++ PythonO(1)O(1)MediumMath, Law of Cosines
3908Valid Digit NumberC++ PythonO(logn)O(1)EasyMath
3927Minimize Array Sum Using Divisible ReplacementsC++ PythonO(n + rlogr)O(r)MediumNumber Theory
3954Sum of Compatible Numbers in Range IC++ PythonO(log(n + k))O(1)EasyBitmasks, Combinatorics, Simulation
3958Minimum Cost to Split into Ones IIC++ PythonO(1)O(1)Medium🔒Math, Invariant
3959Check Good IntegerC++ PythonO(logn)O(1)EasyMath
3984Divisible GameC++ Pythonprecompute: O(r)
runtime: O(nlogx)
O(r + n)MediumNumber Theory, Linear Sieve of Eratosthenes, Kadane's Algorithm, Prefix Sum
3987Minimum Total Cost to Process All ElementsC++ PythonO(n)O(1)MediumMath
3993Maximum Value of an Alternating SequenceC++ PythonO(1)O(1)MediumMath
3996Even Number of Knight MovesC++ PythonO(1)O(1)EasyMath, Parity
4002Count Valid SequencesC++ PythonO(n)O(n)MediumCombinatorics, Stars and Bars
4022K-th Digit in Infinite StringC++ PythonO(logk)O(1)MediumMath
4034Minimum Bishop Moves to Reach TargetC++ PythonO(1)O(1)MediumMath
4035Maximum Valid Split Positions IC++ PythonO(n)O(n)MediumNumber Theory, Prefix Sum
4037Maximum Valid Split Positions IIC++ PythonO(n)O(n)HardNumber Theory, Prefix Sum
4039Sum of Decoded NumbersC++ PythonO(nlogr)O(1)MediumFast Exponentiation
4060Count Evenly Good IntegersC++ PythonO(logr)O(1)Hard🔒Math
4061Minimum Queen Moves to Reach TargetC++ PythonO(1)O(1)EasyMath


Sort

#TitleSolutionTimeSpaceDifficultyTagNote
3011Find if Array Can Be SortedC++ PythonO(n)O(1)MediumSort
3025Find the Number of Ways to Place People IC++ PythonO(n^2)O(1)MediumSort, Array
3027Find the Number of Ways to Place People IIC++ PythonO(n^2)O(1)HardSort, Array
3081Replace Question Marks in String to Minimize Its ValueC++ PythonO(n + 26 * log(26))O(n + 26)MediumGreedy, Counting Sort, Heap, Prefix Sum
3132Find the Integer Added to Array IIC++ PythonO(n)O(n)MediumSort, Paritial Sort, Freq Table
3169Count Days Without MeetingsC++ PythonO(nlogn)O(1)MediumSort
3194Minimum Average of Smallest and Largest ElementsC++ PythonO(nlogn)O(1)EasySort
3309Maximum Possible Number by Binary ConcatenationC++ PythonO(n * logr * logn)O(nlogr)MediumSort, Brute Force
3394Check if Grid can be Cut into SectionsC++ PythonO(nlogn)O(1)MediumSort, Merge Intervals
3431Minimum Unlocked Indices to Sort NumsC++ PythonO(n)O(1)MediumSort
3551Minimum Swaps to Sort by Digit SumC++ PythonO(nlogr + nlogn)O(n)MediumSort
3631Sort Threats by Severity and ExploitabilityC++ PythonO(nlogn)O(1)Medium🔒Sort
3644Maximum K to Sort a PermutationC++ PythonO(n)O(1)MediumSort, Bitmasks, Constructive Algorithms
3667Sort Array By Absolute ValueC++ PythonO(n + r)O(n + r)Easy🔒Sort
3759Count Elements With at Least K Greater ValuesC++ PythonO(n)O(1)MediumSort, Quick Select
3780Maximum Sum of Three Numbers Divisible by ThreeC++ PythonO(n)O(1)MediumSort, Math
3799Word Squares IIC++ PythonO(n^4)O(1)MediumSort, Brute Force, Hash Table
3975Filter Occupied IntervalsC++ PythonO(nlogn)O(n)MediumSort
4065Rearrange Array by Removing Distinct ValuesC++ PythonO(nlogn)O(n)EasyFreq Table, Sort
4068Maximize Meeting Earnings with Idle GapsC++ PythonO(nlogn)O(n)HardSort, Two Pointers, Binary Search, Prefix Sum


Two Pointers

#TitleSolutionTimeSpaceDifficultyTagNote
3006Find Beautiful Indices in the Given Array IC++ PythonO(n)O(min(a + b + x + y, n))MediumKMP Algorithm, Binary Search, Two Pointers
3008Find Beautiful Indices in the Given Array IIC++ PythonO(n)O(min(a + b + x + y, n))HardKMP Algorithm, Binary Search, Two Pointers
3013Divide an Array Into Subarrays With Minimum Cost IIC++ PythonO(nlogd)O(d)HardSliding Window, Heap, Freq Table, Ordered Set, BST, Sorted List
3085Minimum Deletions to Make String K-SpecialC++ PythonO(n + 26)O(n + 26)MediumFreq Table, Counting Sort, Two Pointers
3090Maximum Length Substring With Two OccurrencesC++ PythonO(n + 26)O(26)EasyFreq Table, Sliding Window, Two Pointers
3095Shortest Subarray With OR at Least K IC++ PythonO(n * 30)O(30)EasyBrute Force, Freq Table, Two Pointers
3097Shortest Subarray With OR at Least K IIC++ PythonO(n * 30)O(30)MediumFreq Table, Two Pointers
3171Find Subarray With Bitwise OR Closest to KC++ PythonO(nlogr)O(logr)Hardvariant of Find a Value of a Mysterious Function Closest to TargetDP, Freq Table, Two Pointers, Sliding Window
3206Alternating Groups IC++ PythonO(n)O(1)EasyTwo Pointers, Sliding Window
3208Alternating Groups IIC++ PythonO(n)O(1)MediumTwo Pointers, Sliding Window
3234Count the Number of Substrings With Dominant OnesC++ PythonO(n^(3/2))O(1)MediumTwo Pointers, Sliding Window
3254Find the Power of K-Size Subarrays IC++ PythonO(n)O(1)MediumTwo Pointers, Sliding Window
3255Find the Power of K-Size Subarrays IIC++ PythonO(n)O(1)MediumTwo Pointers, Sliding Window
3258Count Substrings That Satisfy K-Constraint IC++ PythonO(n)O(1)EasyTwo Pointers, Sliding Window
3261Count Substrings That Satisfy K-Constraint IIC++ PythonO(n)O(n)HardTwo Pointers, Sliding Window, Prefix Sum, Hash Table
3264Final Array State After K Multiplication Operations IC++ PythonO(nlogn)O(n)EasySort, Two Pointers, Sliding Window, Fast Exponentiation, Heap, Binary Search, Simulation
3266Final Array State After K Multiplication Operations IIC++ PythonO(nlogn)O(n)HardSort, Two Pointers, Sliding Window, Fast Exponentiation, Heap, Binary Search
3297Count Substrings That Can Be Rearranged to Contain a String IC++ PythonO(n + 26)O(26)MediumTwo Pointers, Sliding Window, Freq Table
3298Count Substrings That Can Be Rearranged to Contain a String IIC++ PythonO(n + 26)O(26)HardTwo Pointers, Sliding Window, Freq Table
3305Count of Substrings Containing Every Vowel and K Consonants IC++ PythonO(n)O(1)MediumTwo Pointers, Sliding Window, Freq Table
3306Count of Substrings Containing Every Vowel and K Consonants IIC++ PythonO(n)O(1)MediumTwo Pointers, Sliding Window, Freq Table
3318Find X-Sum of All K-Long Subarrays IC++ PythonO(nlogn)O(n)EasyTwo Pointers, Sliding Window, Freq Table, Ordered Set, Sorted List
3321Find X-Sum of All K-Long Subarrays IIC++ PythonO(nlogn)O(n)HardTwo Pointers, Sliding Window, Freq Table, Ordered Set, Sorted List
3323Minimize Connected Groups by Inserting IntervalC++ PythonO(nlogn)O(n)Medium🔒Sort, Prefix Sum, Two Pointers, Sliding Window
3325Count Substrings With K-Frequency Characters IC++ PythonO(n + 26)O(26)MediumFreq Table, Two Pointers, Sliding Window
3329Count Substrings With K-Frequency Characters IIC++ PythonO(n + 26)O(26)Hard🔒Freq Table, Two Pointers, Sliding Window
3346Maximum Frequency of an Element After Performing Operations IC++ PythonO(nlogn)O(n)MediumSort, Freq Table, Two Pointers, Sliding Window, Difference Array, Line Sweep
3347Maximum Frequency of an Element After Performing Operations IIC++ PythonO(nlogn)O(n)HardSort, Freq Table, Two Pointers, Sliding Window, Difference Array, Line Sweep
3364Minimum Positive Sum SubarrayC++ PythonO(nlogn)O(n)EasyPrefix Sum, Two Pointers, Sliding Window, Sorted List, BST, Binary Search
3413Maximum Coins From K Consecutive BagsC++ PythonO(nlogn)O(1)MediumSort, Two Pointers, Sliding Window
3420Count Non-Decreasing Subarrays After K OperationsC++ PythonO(n)O(n)HardMono Deque, Two Pointers, Sliding Window
3422Minimum Operations to Make Subarray Elements EqualC++ PythonO(nlogk)O(k)Medium🔒Math, Two Pointers, Sliding Window, Sorted List, BST
3425Longest Special PathC++ PythonO(n + e)O(n + e)HardDFS, Two Pointers, Sliding Window, Prefix Sum
3430Maximum and Minimum Sums of at Most Size K SubarraysC++ PythonO(n)O(k)HardTwo Pointers, Sliding Window, Mono Deque
3439Reschedule Meetings for Maximum Free Time IC++ PythonO(n)O(1)MediumTwo Pointers, Sliding Window
3445Maximum Difference Between Even and Odd Frequency IIC++ PythonO(d^2 * n)O(n)HardPrefix Sum, Two Pointers, Sliding Window
3460Longest Common Prefix After at Most One RemovalC++ PythonO(n)O(1)Medium🔒Two Pointers
3485Longest Common Prefix of K Strings After RemovalC++ PythonO(l * nlogn)O(n)HardSort, Sliding Window, Prefix Sum, Trie
3486Longest Special Path IIC++ PythonO(n + e)O(n + e)HardDFS, Two Pointers, Sliding Window, Prefix Sum
3555Smallest Subarray to Sort in Every Sliding WindowC++ PythonO(n)O(n)Medium🔒Mono Stack, Two Pointers
3567Minimum Absolute Difference in Sliding SubmatrixC++ PythonO(m * n * k^2)O(k^2)MediumBrute Force, Sort, Two Pointers, Sliding Window, BST, Sorted List
3584Maximum Product of First and Last Elements of a SubsequenceC++ PythonO(n)O(1)MediumTwo Pointers, Sliding Window
3589Count Prime-Gap Balanced SubarraysC++ Pythonprecompute: O(r)
runtime: O(n)
O(r)MediumNumber Theory, Linear Sieve of Eratosthenes, Mono Deque, Two Pointers, Sliding Window
3634Minimum Removals to Balance ArrayC++ PythonO(nlogn)O(1)MediumSort, Two Pointers, Sliding Window
3640Trionic Array IIC++ PythonO(n)O(1)EasyTwo Pointers, Sliding Window, Greedy
3641Longest Semi-Repeating SubarrayC++ PythonO(n)O(1)Medium🔒Freq Table, Two Pointers, Sliding Window
3649Number of Perfect PairsC++ PythonO(nlogn)O(1)MediumSort, Two Pointers, Sliding Window, Math
3652Best Time to Buy and Sell Stock using StrategyC++ PythonO(n)O(1)MediumTwo Pointers, Sliding Window
3672Sum of Weighted Modes in SubarraysC++ PythonO(nlogk)O(k)Medium🔒Sorted List, BST, Two Pointers, Sliding Window
3679Minimum Discards to Balance InventoryC++ PythonO(n)O(w)MediumFreq Table, Two Pointers, Sliding Window
3698Split Array With Minimum DifferenceC++ PythonO(n)O(1)MediumTwo Pointers
3740Minimum Distance Between Three Equal Elements IC++ PythonO(n)O(n)EasyHash Table, Two Pointers, Sliding Window
3741Minimum Distance Between Three Equal Elements IIC++ PythonO(n)O(n)MediumHash Table, Two Pointers, Sliding Window
3768Minimum Inversion Count in Subarrays of Fixed LengthC++ PythonO(nlogn)O(n)HardSort, Coordinate Compression, BIT, Fenwick Tree, Two Pointers, Sliding Window
3795Minimum Subarray Length With Distinct Sum At Least KC++ PythonO(n)O(n)MediumFreq Table, Two Pointers, Sliding Window
3802Number of Ways to Paint SheetsC++ PythonO(mlogm)O(m)Hard🔒Prefix Sum, Two Pointers
3835Count Subarrays With Cost Less Than or Equal to KC++ PythonO(n)O(n)MediumMono Deque, Two Pointers, Sliding Window
3844Longest Almost-Palindromic SubstringC++ PythonO(n^2)O(1)MediumTwo Pointers
3845Maximum Subarray XOR with Bounded RangeC++ PythonO(nlogr)O(n)HardTwo Pointers, Sliding Window, Mono Deque, Bitmasks, Prefix Sum, Trie, Hash Table
3851Maximum Requests Without Violating the LimitC++ PythonO(nlogn)O(n)Medium🔒Hash Table, Sort, Deque, Two Pointers, Sliding Window
3859Count Subarrays With K Distinct IntegersC++ PythonO(n)O(n)HardFreq Table, Two Pointers, Sliding Window
3872Longest Arithmetic Sequence After Changing At Most One ElementC++ PythonO(n)O(1)MediumTwo Pointers
3874Valid Subarrays With Exactly One PeakC++ PythonO(n)O(1)Medium🔒Combinatorics, Two Pointers
3937Minimum Operations to Make Array Modulo Alternating IC++ PythonO(n + k)O(k)MediumFreq Table, Two Pointers, Sliding Window
3944Minimum Operations to Make Array Modulo Alternating IIC++ PythonO(n + k)O(k)Hard🔒Freq Table, Two Pointers, Sliding Window
3969Valid Subarrays With Matching Sum Digits IC++ PythonO(nlogr)O(n)MediumBrute Force, Prefix Sum, Two Pointers, Sliding Window
3972Valid Subarrays With Matching Sum Digits IIC++ PythonO(nlogr)O(n)Hard🔒Prefix Sum, Two Pointers, Sliding Window
3992Rearrange String to Avoid Character PairC++ PythonO(n)O(1)EasyTwo Pointers
4001Aggregate Two Time SeriesC++ PythonO(n + m)O(1)MediumTwo Pointers
4031Find All Numbers Disappeared in an Array IIC++ PythonO(r)O(r)MediumSort, Two Pointers, Hash Table
4032Longest Subarray With at Most K Distinct Prime FactorsC++ Pythonctor: O(r)
runtime: O(nlogr)
O(r)MediumNumber Theory, Linear Sieve of Eratosthenes, Freq Table, Two Pointers, Sliding Window
4033Valid K-Unique Subarrays IC++ PythonO(n + q)O(n)HardTwo Pointers, Sliding Window, Hash Table, Prefix Sum, BIT, Fenwick Tree, Sort, Coordinate Compression, Mo's Algorithm
4042Valid K-Unique Subarrays IIC++ PythonO(n + q)O(n)Hard🔒Two Pointers, Sliding Window, Hash Table, Prefix Sum
4044Count Good Cyclic RotationsC++ PythonO(n)O(1)MediumTwo Pointers, Sliding Window
4067Longest Subarray With Restricted Pair SumsC++ PythonO(n * r)O(r)MediumFreq Table, Two Pointers, Sliding Window


Recursion

#TitleSolutionTimeSpaceDifficultyTagNote


#TitleSolutionTimeSpaceDifficultyTagNote
3048Earliest Second to Mark Indices IC++ PythonO(mlogm)O(n)MediumBinary Search, Greedy
3049Earliest Second to Mark Indices IIC++ PythonO((m + nlogn) *logm)O(n)HardBinary Search, Greedy, Heap
3104Find Longest Self-Contained SubstringC++ PythonO(n + 26^3 * logn)O(n)Hard🔒Brute Force, Freq Table, Two Pointers, Hash Table, Binary Search
3116Kth Smallest Amount With Single Denomination CombinationC++ PythonO(n * 2^n * logk)O(2^n)HardBinary Search, Principle of Inclusion and Exclusion, Number Theory
3134Find the Median of the Uniqueness ArrayC++ PythonO(nlogn)O(n)HardBinary Search, Two Pointers, Sliding Window
3135Equalize Strings by Adding or Removing Characters at EndsC++ PythonO((n + m) * log(min(n, m)))O(min(n, m))Medium🔒Binary Search, Rabin-Karp Algorithm, Rolling Hash, DP
3145Find Products of Elements of Big ArrayC++ PythonO(q * (logr)^2)O(1)HardBinary Search, Combinatorics, Bitmasks, Fast Exponentiation
3231Minimum Number of Increasing Subsequence to Be RemovedC++ PythonO(nlogn)O(n)Hard🔒, variant of Longest Increasing SubsequenceBinary Search
3233Find the Count of Numbers Which Are Not SpecialC++ Pythonprecompute: O(sqrt(r))
runtime: O(logr)
O(sqrt(r))MediumNumber Theory, Linear Sieve of Eratosthenes, Binary Search
3281Maximize Score of Numbers in RangesC++ PythonO(nlogr)O(1)MediumBinary Search, Greedy
3288Length of the Longest Increasing PathC++ PythonO(nlogn)O(n)HardSort, Binary Search, Longest Increasing Subsequence
3296Minimum Number of Seconds to Make Mountain Height ZeroC++ PythonO(nlogr)O(1)MediumBinary Search, Quadratic Equation, Heap
3356Zero Array Transformation IIC++ PythonO((n + q) * logn)O(n)MediumBinary Search, Line Sweep
3357Minimize the Maximum Adjacent Element DifferenceC++ PythonO(nlogr)O(1)HardBinary Search
3398Smallest Substring With Identical Characters IC++ PythonO(nlogn)O(1)HardBinary Search, Greedy
3399Smallest Substring With Identical Characters IIC++ PythonO(nlogn)O(1)HardBinary Search, Greedy
3449Maximize the Minimum Game ScoreC++ PythonO(n * log(m * r))O(1)HardBinary Search, Greedy
3464Maximize the Distance Between Points on a SquareC++ PythonO(nlogn + nlogs)O(n)HardSort, Binary Search, Greedy, Two Pointers, Sliding Window
3477Fruits Into Baskets IIC++ PythonO(nlogn)O(n)EasySegment Tree, Binary Search, Brute Force
3479Fruits Into Baskets IIIC++ PythonO(nlogn)O(n)MediumSegment Tree, Binary Search
3520Minimum Threshold for Inversion Pairs CountC++ PythonO(nlogn * logr)O(n)Medium🔒Binary Search, Sorted List, Ordered Set
3605Minimum Stability Factor of ArrayC++ PythonO(nlogn * logr)O(nlogn)HardNumber Theory, Binary Search, RMQ, Sparse Table, Greedy
3722Lexicographically Smallest String After ReverseC++ PythonO(nlogn)O(n)MediumString, Brute Force, Binary Search, Rabin-Karp Algorithm, Rolling Hash
3733Minimum Time to Complete All DeliveriesC++ PythonO(logr + logd)O(1)MediumBinary Search
3735Lexicographically Smallest String After Reverse IIC++ PythonO(nlogn)O(n)Hard🔒Binary Search, Rabin-Karp Algorithm, Rolling Hash
3771Total Score of Dungeon RunsC++ PythonO(nlogn)O(n)MediumPrefix Sum, Binary Search
3807Minimum Cost to Repair Edges to Traverse a GraphC++ PythonO((n + m) * logr)O(n + m)Medium🔒Binary Search, BFS
3824Minimum K to Reduce Array Within LimitC++ PythonO(nlogn + nlogr)O(1)MediumBinary Search
3825Longest Strictly Increasing Subsequence With Non-Zero Bitwise ANDC++ PythonO(logr * nlogn)O(n)MediumBitmasks, LIS, Longest Increasing Subsequence, Binary Search
3826Minimum Partition ScoreC++ PythonO(nlogn + nlogr)O(n)HardPrefix Sum, DP, Convex Hull Trick, WQS Binary Search, Alien Trick
3893Maximum Team Size with Overlapping IntervalsC++ PythonO(nlogn)O(n)Medium🔒Sort, Binary Search
3911K-th Smallest Remaining Even Integer in Subarray QueriesC++ PythonO(n + qlogn)O(n)HardPrefix Sum, Binary Search
3920Maximize Fixed Points After DeletionsC++ PythonO(nlogn)O(n)HardSort, Binary Search, Longest Increasing Subsequence
3924Minimum Threshold Path With Limited Heavy EdgesC++ PythonO((n + e) * loge)O(n + e)HardBinary Search, 0-1 BFS, Deque
3929Minimum Partition Score IIC++ PythonO(nlogn + nlogr)O(n)Hard🔒Prefix Sum, DP, Convex Hull Trick, WQS Binary Search, Alien Trick
3932Count K-th Roots in a RangeC++ PythonO(logr * logk)O(1)MediumBinary Search, Fast Exponentiation
3934Smallest Unique SubarrayC++ PythonO(nlogn)O(n)HardBinary Search, Rabin-Karp Algorithm, Rolling Hash
3956Maximum Sum of M Non-Overlapping Subarrays IC++ PythonO(nlogr)O(n)HardPrefix Sum, DP, Mono Deque, WQS Binary Search, Alien Trick
3957Maximum Sum of M Non-Overlapping Subarrays IIC++ PythonO(nlogr)O(n)HardPrefix Sum, DP, Mono Deque, WQS Binary Search, Alien Trick
3971Maximum Total ValueC++ PythonO(nlogr)O(1)HardBinary Search


Binary Search Tree

#TitleSolutionTimeSpaceDifficultyTagNote
3072Distribute Elements Into Two Arrays IIC++ PythonO(nlogn)O(n)HardSorted List, Ordered Set
3073Maximum Increasing Triplet ValueC++ PythonO(nlogn)O(n)Medium🔒Sorted List, BST, Prefix Sum
3161Block Placement QueriesC++ PythonO(qlogq)O(q)HardSorted List, BST, BIT, Fenwick Tree, Segment Tree
3165Maximum Sum of Subsequence With Non-adjacent ElementsC++ PythonO(n + qlogn)O(n)HardSegment Tree
3526Range XOR Queries with Subarray ReversalsC++ PythonO(n + qlogn)O(n)Hard🔒Treap
3930Power Update After K-th Largest Insertion IIC++ PythonO((n + q) * log(n * q) + q * logr)O(n + q)Hard🔒Sorted List, Ordered Set, Sort, Coordinate Compression, BIT, Fenwick Tree, Fast Exponentiation
3935Power Update After K-th Largest Insertion IC++ PythonO((n + q) * log(n * q) + q * logr)O(n + q)Medium🔒Sorted List, Ordered Set, Sort, Coordinate Compression, BIT, Fenwick Tree, Fast Exponentiation


#TitleSolutionTimeSpaceDifficultyTagNote
3157Find the Level of Tree with Minimum SumC++ PythonO(n)O(w)Medium🔒BFS
3286Find a Safe Walk Through a GridC++ PythonO(m * n)O(m * n)Mediumvariant of Minimum Obstacle Removal to Reach Corner0-1 BFS, Deque
3373Maximize the Number of Target Nodes After Connecting Trees IIC++ PythonO(n + m)O(n + m)HardBFS
3528Unit Conversion IC++ PythonO(n)O(n)MediumBFS
3535Unit Conversion IIC++ PythonO(n + qlogm)O(n)Medium🔒BFS, Fast Exponentiation
3552Grid Teleportation TraversalC++ PythonO(m * n)O(m * n)Medium0-1 BFS, Deque
3568Minimum Moves to Clean the ClassroomC++ PythonO(m * n * 2^l)O(m * n * 2^l)MediumBFS, Bitmasks
3619Count Islands With Total Value Divisible by KC++ PythonO(m * n)O(m + n)MediumBFS, Flood Fill
3629Minimum Jumps to Reach End via Prime TeleportationC++ Pythonprecompute: O(r)
runtime: O(nlogr)
O(r + nlogr)MediumNumber Theory, Linear Sieve of Eratosthenes, BFS
3690Split and Merge Array TransformationC++ PythonO(n^4 * n!)O(n * n!)MediumBFS
3695Maximize Alternating Sum Using SwapsC++ PythonO(n + s)O(n + s)HardBFS, Flood Fill, Quick Select
3786Total Sum of Interaction Cost in Tree GroupsC++ PythonO(nlogn)O(n)HardBFS, DFS, Small-to-Large Merging
3787Find Diameter Endpoints of a TreeC++ PythonO(n)O(n)Medium🔒BFS, Tree Diameter
3820Pythagorean Distance Nodes in a TreeC++ PythonO(n)O(n)MediumBFS
3831Median of a Binary Search Tree LevelC++ PythonO(n)O(n)Medium🔒BFS
3902Zigzag Level Sum of Binary TreeC++ PythonO(n)O(w)Hard🔒BFS
3905Multi Source Flood FillC++ PythonO(n * m)O(n * m)MediumSort, BFS, Flood Fill
3923Minimum Generations to Target PointC++ PythonO(7^6)O(7^3)MediumBFS
3991Sort Array Using Prefix ReversalsC++ PythonO(n! * n * m)O(n! * n)Medium🔒BFS, Bi-BFS
4047Minimum Operations to Make XOR of All Elements ZeroC++ PythonO(n + r * d)O(r + d)Hard🔒BFS, Bi-BFS


#TitleSolutionTimeSpaceDifficultyTagNote
3004Maximum Subtree of the Same ColorC++ PythonO(n)O(h)Medium🔒DFS
3067Count Pairs of Connectable Servers in a Weighted Tree NetworkC++ PythonO(n^2)O(n)MediumDFS, BFS
3203Find Minimum Diameter After Merging Two TreesC++ PythonO(n + m)O(n + m)Hardvariant of Tree DiameterDFS, BFS, Tree DP, Tree Diameter
3249Count the Number of Good NodesC++ PythonO(n)O(h)MediumDFS
3319K-th Largest Perfect Subtree Size in Binary TreeC++ PythonO(n)O(n)MediumDFS, Quick Select
3327Check if DFS Strings Are PalindromesC++ PythonO(n)O(n)HardDFS, Manacher's Algorithm
3331Find Subtree Sizes After ChangesC++ PythonO(n)O(n)MediumDFS, Hash Table
3367Maximize Sum of Weights after Edge RemovalsC++ PythonO(n)O(n)HardDFS, Quick Select
3590Kth Smallest Path XOR SumC++ PythonO(n * (logn)^2 + qlogn)O(n + q)HardDFS, Small-to-Large Merging, Ordered Set, Sorted List
3593Minimum Increments to Equalize Leaf PathsC++ PythonO(n)O(n)MediumDFS
3607Power Grid MaintenanceC++ PythonO(c + n + q)O(c + n)MediumDFS, Flood Fill, Sort
4015Weighted Sum of a TreeC++ PythonO(n)O(n)MediumDFS, Tree DP
4018Total Sum of Interaction Cost in Tree Groups IIC++ PythonO(nlogn)O(n)Hard🔒DFS, Small-to-Large Merging


Backtracking

#TitleSolutionTimeSpaceDifficultyTagNote
3211Generate Binary Strings Without Adjacent ZerosC++ PythonO(n * 2^n)O(n)MediumBacktracking, BFS
3437Permutations IIIC++ PythonO(n * n!)O(n)Medium🔒Backtracking, Bitmasks
3565Sequential Grid Path CoverC++ PythonO(m * n * 3^(m * n))O(m * n)Medium🔒Backtracking
3669Balanced K-Factor DecompositionC++ Pythonprecompute: O(rlogr)
runtime: O(k * (logn)^(k - 1))
O(rlogr)MediumBacktracking, Number Theory
3955Valid Binary Strings With Cost LimitC++ PythonO(n * 2^n)O(n)MediumBacktracking, Bitmasks


Dynamic Programming

#TitleSolutionTimeSpaceDifficultyTagNote
3018Maximum Number of Removal Queries That Can Be Processed IC++ PythonO(n^2)O(n^2)Hard🔒DP
3020Find the Maximum Number of Elements in SubsetC++ PythonO(n)O(n)MediumFreq Table, DP
3040Maximum Number of Operations With the Same Score IIC++ PythonO(n^2)O(n^2)MediumMemoization
3041Maximize Consecutive Elements in an Array After ModificationC++ PythonO(nlogn)O(1)HardSort, DP
3077Maximum Strength of K Disjoint SubarraysC++ PythonO(k * n)O(n)HardDP, Greedy, Kadane's Algorithm
3082Find the Sum of the Power of All SubsequencesC++ PythonO(n * k)O(k)HardDP, Combinatorics
3098Find the Sum of Subsequence PowersC++ PythonO(n^3 * k)O(n^2)HardDP, Prefix Sum, Two Pointers
3101Count Alternating SubarraysC++ PythonO(n)O(1)MediumDP
3117Minimum Sum of Values by Dividing Array[C++](./C++/minimum-sum-of-values-by-dividi

Truncated — view the full README on GitHub.

algorithm
algorithms
cpp
cpp11
data-structure
interview-practice
interview-preparation
interview-questions
leetcode
leetcode-cpp
leetcode-python
leetcode-solutions
modern-cpp
python

Project health

Overall

3.5/10

Maintained

10/10

Code review

0/10
OpenSSF Scorecard

Significant stargazers