LeetCode

June 16, 2026 · View on GitHub

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 * 292^{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

⬆️ Back to Top

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
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

⬆️ Back to Top

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

⬆️ Back to Top

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

⬆️ Back to Top

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

⬆️ Back to Top

Queue

#TitleSolutionTimeSpaceDifficultyTagNote

⬆️ Back to Top

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

⬆️ Back to Top

Tree

#TitleSolutionTimeSpaceDifficultyTagNote
3109Find the Index of PermutationC++ PythonO(nlogn)O(n)🔒, Mediumvariant 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

⬆️ Back to Top

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, 26226^{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

⬆️ Back to Top

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

⬆️ Back to Top

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
3886Sum of Sortable IntegersC++ PythonO(nlog(logn))O(n)HardPrefix Sum, Number Theory

⬆️ Back to Top

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

⬆️ Back to Top

Recursion

#TitleSolutionTimeSpaceDifficultyTagNote

⬆️ Back to Top

#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 + 26326^{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

⬆️ Back to Top

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

⬆️ Back to Top

#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(767^{6})O(737^{3})MediumBFS

⬆️ Back to Top

#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

⬆️ Back to Top

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

⬆️ Back to Top

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 ArrayC++ PythonO(n * m * logr)O(n + logr)HardMemoization, DP, RMQ, Sparse Table, Mono Deque, Two Pointers
3122Minimum Number of Operations to Satisfy ConditionsC++ PythonO(n * (m + 10))O(10)MediumDP
3129Find All Possible Stable Binary Arrays IC++ PythonO(n * m)O(n * m)MediumDP
3130Find All Possible Stable Binary Arrays IIC++ PythonO(n * m)O(n * m)HardDP
3141Maximum Hamming DistancesC++ PythonO(m * 2^m)O(2^m)Hard🔒Bitmasks, BFS, Knapsack DP
3144Minimum Substring Partition of Equal Character FrequencyC++ PythonO(n * (n + 26))O(n + 26)MediumDP, Freq Table
3148Maximum Difference Score in a GridC++ PythonO(m * n)O(1)MediumDP
3149Find the Minimum Cost Array PermutationC++ PythonO((n-1)^2 * 2^(n-1))O((n-1) * 2^(n-1))HardDP, Backtracing
3176Find the Maximum Length of a Good Subsequence IC++ PythonO(n * k)O(n * k)MediumDP
3177Find the Maximum Length of a Good Subsequence IIC++ PythonO(n * k)O(n * k)HardDP
3180Maximum Total Reward Using Operations IC++ PythonO(n * k)O(n * k)MediumSort, DP, Bitset
3181Maximum Total Reward Using Operations IIC++ PythonO(n * k)O(n * k)HardSort, DP, Bitset
3186Maximum Total Damage With Spell CastingC++ PythonO(nlogn)O(n)MediumSort, DP, Two Pointers, Sliding window, Deque
3193Count the Number of InversionsC++ PythonO(n * k)O(n + k)Hardvariant of K Inverse Pairs ArrayKnapsack DP, Combinatorics, Sliding Window, Two Pointers
3196Maximize Total Cost of Alternating SubarraysC++ PythonO(n)O(1)MediumDP
3197Find the Minimum Area to Cover All Ones IIC++ PythonO(max(n, m)^2)O(max(n, m)^2)HardArray, Brute Force, Prefix Sum, Binary Search, RMQ, Sparse Table, DP
3201Find the Maximum Length of Valid Subsequence IC++ PythonO(n)O(1)MediumBrute Force, DP
3202Find the Maximum Length of Valid Subsequence IIC++ PythonO(n * k)O(k)MediumDP
3209Number of Subarrays With AND Value of KC++ PythonO(nlogr)O(logr)Hardvariant of Find Subarray With Bitwise OR Closest to KDP
3212Count Submatrices With Equal Frequency of X and YC++ PythonO(n * m)O(n * m)MediumDP
3213Construct String with Minimum CostC++ PythonO(n^2 + w * l)O(t)HardDP, Trie
3225Maximum Score From Grid OperationsC++ PythonO(n^3)O(n)HardPrefix Sum, DP
3241Time Taken to Mark All NodesC++ PythonO(n)O(n)HardTree DP, BFS, DFS
3253Construct String with Minimum Cost (Easy)C++ PythonO(n * w * l)O(l)Medium🔒DP, Trie
3259Maximum Energy Boost From Two DrinksC++ PythonO(n)O(1)MediumDP
3269Constructing Two Increasing ArraysC++ PythonO(m * n)O(min(m, n))Hard🔒DP
3277Maximum XOR Score Subarray QueriesC++ PythonO(n^2 + q)O(n^2)HardDP
3283Maximum Number of Moves to Kill All PawnsC++ PythonO(p^2 * 2^p)O(p * 2^p)HardBFS, Bitmasks, DP
3287Find the Maximum Sequence Value of ArrayC++ PythonO(n * r + r^2)O(r)HardBitmasks, Prefix Sum, DP
3290Maximum Multiplication ScoreC++ PythonO(n)O(1)MediumDP
3291Minimum Number of Valid Strings to Form Target IC++ PythonO(n + w * l)O(n + t)MediumKMP, Rabin-Karp Algorithm, Rolling Hash, Hash Table, Two Pointers, Sliding Window, DP, Aho-Corasick Automata, Trie
3292Minimum Number of Valid Strings to Form Target IIC++ PythonO(n + w * l)O(n + t)HardKMP, Rabin-Karp Algorithm, Rolling Hash, Hash Table, Two Pointers, Sliding Window, DP, Aho-Corasick Automata, Trie
3313Find the Last Marked Nodes in TreeC++ PythonO(n)O(n)Hard🔒, variant of Time Taken to Mark All NodesBFS, DFS, Tree DP, Tree Diameter
3316Find Maximum Removals From Source StringC++ PythonO(n * m)O(n + m)MediumDP
3320Count The Number of Winning SequencesC++ PythonO(n^2)O(n)HardDP
3332Maximum Points Tourist Can EarnC++ PythonO(k * n^2)O(n)HardDP
3333Find the Original Typed String IIC++ PythonO(n + k^2)O(n + k)HardDP
3335Total Characters in String After Transformations IC++ Pythonprecompute: O(t + 26)
runtime: O(n)
O(t + 26)MediumDP, Matrix Exponentiation, Precompute
3336Find the Number of Subsequences With Equal GCDC++ Pythonprecompute: O(max_r^2 * log(max_r))
runtime: O(n + r^2)
O(max_r^2)HardDP, Number Theory, Mobius Function, Principle of Inclusion-Exclusion, Basel Problem
3337Total Characters in String After Transformations IIC++ PythonO(n + 26326^{3} * logt)O(26226^{2})HardDP, Matrix Exponentiation
3343Count Number of Balanced PermutationsC++ PythonO(n^2)O(n^2)HardDP, Combinatorics
3351Sum of Good SubsequencesC++ PythonO(n)O(n)HardFreq Table, DP
3352Count K-Reducible Numbers Less Than NC++ PythonO(n^2)O(n)HardDP, Combinatorics
3359Find Sorted Submatrices With Maximum Element at Most KC++ PythonO(m * n)O(m)Hard🔒, variant of Count Submatrices With All OnesMono Stack, DP
3363Find the Maximum Number of Fruits CollectedC++ PythonO(n^2)O(1)HardDP
3366Minimum Array SumC++ PythonO(nlogn)O(n)MediumDP, Greedy, Case Works
3372Maximize the Number of Target Nodes After Connecting Trees IC++ PythonO(nlogn + mlogm)O(n + m)MediumBrute Force, BFS, DFS, Tree DP, Centroid Decomposition, Prefix Sum
3381Maximum Subarray Sum With Length Divisible by KC++ PythonO(n)O(k)MediumPrefix Sum, DP
3388Count Beautiful Splits in an ArrayC++ PythonO(n^2)O(n)MediumDP, Z-Function
3389Minimum Operations to Make Character Frequencies EqualC++ PythonO(26 * n)O(26)HardFreq Table, DP
3393Count Paths With the Given XOR ValueC++ PythonO(m * n * r)O(n * r)MediumDP
3409Longest Subsequence With Decreasing Adjacent DifferenceC++ PythonO(r^2 + n * r)O(r^2)MediumDP
3414Maximum Score of Non-overlapping IntervalsC++ PythonO(nlogn + n * k^2)O(n * k^2)HardDP, Binary Search
3418Maximum Amount of Money Robot Can EarnC++ PythonO(m * n)O(min(m, n))MediumDP
3429Paint House IVC++ PythonO(n * l^4)O(l^2)MediumDP
3434Maximum Frequency After Subarray OperationC++ PythonO(n)O(n)MediumFreq Table, DP
3441Minimum Cost Good CaptionC++ PythonO(26 * n)O(26 * n)HardDP, Backtracing
3444Minimum Increments for Target Multiples in an ArrayC++ PythonO(logr * m * 2^m + n * 3^m)O(2^m)HardBitmasks, Number Theory, DP, Submask Enumeration
3459Length of Longest V-Shaped Diagonal SegmentC++ PythonO(n * m)O(n * m)HardMemoization, DP
3466Maximum Coin CollectionC++ PythonO(n)O(1)Medium🔒DP
3469Find Minimum Cost to Remove Array ElementsC++ PythonO(n^2)O(n)MediumDP, Greedy
3472Longest Palindromic Subsequence After at Most K OperationsC++ PythonO(n^2 * k)O(n^2 * k)MediumDP
3473Sum of K Subarrays With Length at Least MC++ PythonO(k * n)O(n)MediumPrefix Sum, DP
3489Zero Array Transformation IVC++ PythonO(n^2 * r * logq)O(r)MediumBinary Search, DP
3490Count Beautiful NumbersC++ PythonO(logr * 2 * 10 * s)O(logr * 2 * 10 * s)HardDP
3500Minimum Cost to Divide Array Into SubarraysC++ PythonO(nlogn)O(n)HardPrefix Sum, DP, Convex Hull Trick
3503Longest Palindrome After Substring Concatenation IC++ PythonO(n * m)O(n + m)MediumManacher's Algorithm, DP
3504Longest Palindrome After Substring Concatenation IIC++ PythonO(n * m)O(n + m)HardManacher's Algorithm, DP
3505Minimum Operations to Make Elements Within K Subarrays EqualC++ PythonO(nlogx + k * n)O(n)HardTwo Heaps, Two BSTs, Two Sorted Lists, DP
3509Maximum Product of Subsequences With an Alternating Sum Equal to KC++ PythonO(n * k * l)O(n * k * l)HardDP
3524Find X Value of Array IC++ PythonO(n * k)O(k)MediumDP
3525Find X Value of Array IIC++ PythonO(n * k + q * k * logn)O(n * k)HardDP, Segment Tree
3530Maximum Profit from Valid Topological Order in DAGC++ PythonO(n * 2^n)O(2^n)HardDP, Bitmasks
3533Concatenated DivisibilityC++ PythonO(nlogr + k * n * 2^n)O(logr + k * 2^n)HardDP, Bitmasks, Backtracing
3538Merge Operations for Minimum Travel TimeC++ PythonO((n-k) * k^3)O(k^2)HardPrefix Sum, DP
3539Find Sum of Array Product of Magical SequencesC++ PythonO(n * k * m^2)O(k * m^2)HardDP, Combinatorics
3543Maximum Weighted K-Edge PathC++ PythonO(k * e * t)O(n * t)MediumDP
3544Subtree Inversion SumC++ PythonO(n)O(n)HardDFS, Tree DP
3562Maximum Profit from Trading Stocks with DiscountsC++ PythonO(n * b)O(n + b)HardDFS, Tree DP
3563Lexicographically Smallest String After Adjacent RemovalsC++ PythonO(n^3)O(n^2)HardDP
3573Best Time to Buy and Sell Stock VC++ PythonO(n * k)O(k)MediumDP
3574Maximize Subarray GCD ScoreC++ PythonO(nlogn * logr)O(n + logr)HardBrute Force, Number Theory, Suffix-GCD States, DP, Binary Search
3575Maximum Good Subtree ScoreC++ PythonO(n * (2102^{10})^2)O(2102^{10})HardBitmasks, DFS, Tree DP
3578Count Partitions With Max-Min Difference at Most KC++ PythonO(n)O(n)MediumMono Deque, Two Pointers, Sliding Window, DP, Prefix Sum
3579Minimum Steps to Convert String with OperationsC++ PythonO(n^2)O(26226^{2})HardDP
3583Count Special TripletsC++ PythonO(n)O(n)MediumDP, Freq Table
3592Inverse Coin ChangeC++ PythonO(n^2)O(1)MediumDP
3595Once TwiceC++ PythonO(n)O(1)Medium🔒DP, Bitmasks
3599Partition Array to Minimize XORC++ PythonO(n^2 * k)O(n)MediumDP, Prefix Sum
3603Minimum Cost Path with Alternating Directions IIC++ PythonO(m * n)O(1)MediumDP
3610Minimum Number of Primes to Sum to TargetC++ PythonO(nlog(log(min(m, n))) + m * n)O(n)Medium🔒Number Theory, Knapsack DP
3615Longest Palindromic Path in GraphC++ PythonO(n^4 * 2^n)O(n + e)HardBitmasks, DP, Freq Table
3628Maximum Number of Subsequences After One InsertingC++ PythonO(n)O(1)MediumPrefix Sum, DP
3647Maximum Weight in Two BagsC++ PythonO(n * w1 * w2)O(w1 * w2)Medium🔒DP, Bitset
3651Minimum Cost Path with TeleportationsC++ PythonO(k * (m * n + r))O(m * n + r)HardDP, Prefix Sum
3654Minimum Sum After Divisible Sum DeletionsC++ PythonO(n + k)O(k)MediumDP, Prefix Sum
3661Maximum Walls Destroyed by RobotsC++ PythonO(nlogn + mlogm)O(n)HardSort, DP, Two Pointers
3665Twisted Mirror Path CountC++ PythonO(m * n)O(min(m, n))MediumDP
3670Maximum Product of Two Integers With No Common BitsC++ PythonO(n + rlogr)O(r)MediumDP, Bitmasks
3685Subsequence Sum After Capping ElementsC++ PythonO(nlogn + n * k)O(k)MediumSort, DP, Bitmasks
3686Number of Stable SubsequencesC++ PythonO(n)O(1)HardDP
3693Climbing Stairs IIC++ PythonO(n)O(1)MediumDP
3699Number of ZigZag Arrays IC++ PythonO(n * (r - l))O(r - l)HardDP
3704Count No-Zero Pairs That Sum to NC++ PythonO(10 * 242^{4} * logn)O(232^{3})HardDP
3717Minimum Operations to Make the Array BeautifulC++ PythonO(n * rlogr)O(r)Medium🔒DP
3725Count Ways to Choose Coprime Integers from RowsC++ PythonO(n * rlogr)O(r)HardDP, Number Theory, Linear Sieve of Eratosthenes, Mobius Function, Principle of Inclusion-Exclusion
3742Maximum Path Score in a GridC++ PythonO(m * n * k)O(m * n * k)MediumDP
3743Maximize Cyclic Partition ScoreC++ PythonO(n * k)O(k)Hardvariant of Best Time to Buy and Sell Stock VDP
3753Total Waviness of Numbers in Range IIC++ PythonO(logn * 11 * 11 * 2 * 2 * 10)O(11 * 11 * 2 * 2)HardDP, Memoization
3757Number of Effective SubsequencesC++ PythonO((n + r) * logr)O(n + r)HardSOS DP, Principle of Inclusion and Exclusion
3772Maximum Subgraph Score in a TreeC++ PythonO(n)O(n)HardBFS, Tree DP
3791Number of Balanced Integers in a RangeC++ PythonO((logn)^2)O(logn)HardDP, Memoization
3801Minimum Cost to Merge Sorted ListsC++ PythonO(l * nlogn + 2^n * log(n * l) * n * logl + 3^n)O(n * l + 2^n)HardDP, Sort, Heap, Binary Search, Submask Enumeration
3811Number of Alternating XOR PartitionsC++ PythonO(n)O(1)MediumDP, Freq Table
3830Longest Alternating Subarray After Removing At Most One ElementC++ PythonO(n)O(1)HardDP, Prefix Sum
3836Maximum Score Using Exactly K PairsC++ PythonO(n * m * k)O(min(n, m) * k)HardDP
3840House Robber VC++ PythonO(n)O(1)MediumDP
3850Count Sequences to KC++ PythonO(3^(n/2))O(3^(n/2))HardDP, Meet in The Middle
3864Minimum Cost to Partition a Binary StringC++ PythonO(n)O(n)HardPrefix Sum, Divide and Conquer, DP
3869Count Fancy Numbers in a RangeC++ PythonO(g * d + d^2)O(g + d)HardBFS, DP, Principle of Inclusion and Exclusion
3877Minimum Removals to Achieve Target XORC++ PythonO(n * r)O(r)MediumBitmasks, DP, BFS
3882Minimum XOR Path in a GridC++ PythonO(m * n * r)O(n * r)MediumDP
3883Count Non Decreasing Arrays With Given Digit SumsC++ Pythonprecompute: O(rlogr)
runtime: O(n * r)
O(r)MediumDP, Prefix Sum
3891Minimum Increase to Maximize Special IndicesC++ PythonO(n)O(1)MediumDP
3906Count Good Integers on a Grid PathC++ PythonO(16 * 2 * 10 * 10)O(16 + 2 * 10)HardMemoization, DP
3916Number of ZigZag Arrays IIIC++ PythonO(n^3)O(n)Hard🔒DP, Prefix Sum, Combinatorics, Lagrange Interpolation
3939Count Non Adjacent Subsets in a Rooted TreeC++ PythonO(n * k^2)O(n * k)Hard🔒Topological Sort, Tree DP
3946Maximum Number of Items From Sale IC++ PythonO(rlogr + n * b)O(r + b)MediumFreq Table, Knapsack DP
3949Subtree Inversion Sum IIC++ PythonO(n * k)O(n + h * k)Hard🔒DFS, Tree DP
3953Maximum Score with Co-Prime ElementC++ PythonO(n + rlogr)O(r)HardDP, Number Theory, Linear Sieve of Eratosthenes, Mobius Function, Principle of Inclusion-Exclusion

⬆️ Back to Top

Greedy

#TitleSolutionTimeSpaceDifficultyTagNote
3002Maximum Size of a Set After RemovalsC++ PythonO(n)O(n)MediumMath, Hash Table, Greedy
3003Maximize the Number of Partitions After OperationsC++ PythonO(n)O(n)HardPrefix Sum, Greedy
3012Minimize Length of Array Using OperationsC++ PythonO(n)O(1)MediumGreedy
3014Minimum Number of Pushes to Type Word IC++ PythonO(4)O(1)EasyFreq Table, Greedy
3016Minimum Number of Pushes to Type Word IIC++ PythonO(n)O(26)MediumFreq Table, Greedy
3022Minimize OR of Remaining Elements Using OperationsC++ PythonO(nlogr)O(1)HardBitmasks, Greedy
3035Maximum Palindromes After OperationsC++ PythonO(n * l + nlogn)O(n)MediumFreq Table, Greedy, Sort
3068Find the Maximum Sum of Node ValuesC++ PythonO(n)O(1)HardGreedy
3074Apple Redistribution into BoxesC++ PythonO(nlogn)O(1)EasySort, Greedy
3075Maximize Happiness of Selected ChildrenC++ PythonO(nlogn)O(1)MediumSort, Greedy
3086Minimum Moves to Pick K OnesC++ PythonO(n)O(n)HardPrefix Sum, Greedy
3088Make String Anti-palindromeC++ PythonO(n + 26)O(26)Hard🔒Freq Table, Counting Sort, Greedy, Two Pointers
3106Lexicographically Smallest String After Operations With ConstraintC++ PythonO(n)O(1)MediumGreedy
3107Minimum Operations to Make Median of Array Equal to KC++ PythonO(n)O(1)MediumSort, Quick Select, Greedy
3111Minimum Rectangles to Cover PointsC++ PythonO(nlogn)O(n)MediumSort, Greedy
3114Latest Time You Can Obtain After Replacing CharactersC++ PythonO(1)O(1)EasyString, Greedy
3119Maximum Number of Potholes That Can Be FixedC++ PythonO(n)O(n)Medium🔒Sort, Counting Sort, Greedy
3170Lexicographically Minimum String After Removing StarsC++ PythonO(n + 26)O(n + 26)MediumGreedy, Hash Table, Stack
3189Minimum Moves to Get a Peaceful BoardC++ PythonO(n)O(n)Medium🔒, variant of Distribute Coins in Binary TreeCounting Sort, Prefix Sum, Greedy
3191Minimum Operations to Make Binary Array Elements Equal to One IC++ PythonO(n)O(1)MediumGreedy
3192Minimum Operations to Make Binary Array Elements Equal to One IIC++ PythonO(n)O(1)MediumGreedy
3205Maximum Array Hopping Score IC++ PythonO(n)O(1)Medium🔒DP, Prefix Sum, Greedy
3207Maximum Points After Enemy BattlesC++ PythonO(n)O(1)MediumGreedy
3216Lexicographically Smallest String After a SwapC++ PythonO(n)O(1)EasyGreedy
3218Minimum Cost for Cutting Cake IC++ PythonO(mlogm + nlogn)O(1)MediumMemoization, Greedy
3219Minimum Cost for Cutting Cake IIC++ PythonO(mlogm + nlogn)O(1)HardGreedy
3221Maximum Array Hopping Score IIC++ PythonO(n)O(1)Medium🔒Prefix Sum, Greedy
3228Maximum Number of Operations to Move Ones to the EndC++ PythonO(n)O(1)MediumGreedy
3229Minimum Operations to Make Array Equal to TargetC++ PythonO(n)O(1)Hardvariant of Minimum Number of Increments on Subarrays to Form a Target ArrayGreedy
3239Minimum Number of Flips to Make Binary Grid Palindromic IC++ PythonO(m * n)O(1)MediumArray, Greedy
3240Minimum Number of Flips to Make Binary Grid Palindromic IIC++ PythonO(m * n)O(1)MediumArray, Greedy
3273Minimum Amount of Damage Dealt to BobC++ PythonO(nlogn)O(n)HardSort, Greedy
3282Reach End of Array With Max ScoreC++ PythonO(n)O(1)MediumGreedy
3301Maximize the Total Height of Unique TowersC++ PythonO(nlogn)O(1)MediumSort, Greedy
3302Find the Lexicographically Smallest Valid SequenceC++ PythonO(n + m)O(m)MediumHash Table, Greedy
3362Zero Array Transformation IIIC++ PythonO(n + qlogq)O(q)MediumSort, Heap, Greedy
3397Maximum Number of Distinct Elements After OperationsC++ PythonO(nlogn)O(1)MediumSort, Greedy
3402Minimum Operations to Make Columns Strictly IncreasingC++ PythonO(m * n)O(1)EasyGreedy
3403Find the Lexicographically Largest String From the Box IC++ PythonO(n)O(1)MediumGreedy
3406Find the Lexicographically Largest String From the Box IIC++ PythonO(n)O(1)Hard🔒Greedy
3410Maximize Subarray Sum After Removing All Occurrences of One ElementC++ PythonO(n)O(n)HardPrefix Sum, Greedy, Kadane's Algorithm, Segment Tree
3424Minimum Cost to Make Arrays IdenticalC++ PythonO(nlogn)O(1)MediumSort, Greedy
3443Maximum Manhattan Distance After K ChangesC++ PythonO(n)O(1)MediumGreedy
3457Eat Pizzas!C++ PythonO(nlogn)O(1)MediumSort, Greedy
3458Select K Disjoint Special SubstringsC++ PythonO(n + 26326^{3})O(26)MediumHash Table, Sort, Greedy
3462Maximum Sum With at Most K ElementsC++ PythonO(n * m)O(1)MediumGreedy, Quick Select
3468Find the Number of Copy ArraysC++ PythonO(n)O(1)MediumGreedy
3474Lexicographically Smallest Generated StringC++ PythonO(n + m)O(n + m)HardKMP Algorithm, Z-Function, Two Pointers, Sliding Window, Deque, Greedy
3476Maximize Profit from Task AssignmentC++ PythonO(n + tlogt)O(n)Medium🔒Freq Table, Sort, Greedy
3478Choose K Elements With Maximum SumC++ PythonO(nlogn)O(n)MediumSort, Greedy, Two Pointers, Heap
3480Maximize Subarrays After Removing One Conflicting PairC++ PythonO(n + m)O(n + m)HardGreedy
3494Find the Minimum Amount of Time to Brew PotionsC++ PythonO(n * m)O(1)MediumPrefix Sum, Greedy
3494Find the Minimum Amount of Time to Brew PotionsC++ PythonO(n * m)O(1)MediumPrefix Sum, Greedy
3495Minimum Operations to Make Array Elements ZeroC++ PythonO(qlogr)O(1)HardGreedy
3496Maximize Score After Pair DeletionsC++ PythonO(n)O(1)Medium🔒Greedy
3499Maximize Active Section with Trade IC++ PythonO(n)O(1)MediumGreedy
3501Maximize Active Section with Trade IIC++ PythonO(nlogn + q)O(nlogn)HardGreedy, RMQ, Sparse Table
3506Find Time Required to Eliminate Bacterial StrainsC++ PythonO(nlogn)O(1)Hard🔒Heap, Greedy
3511Make a Positive ArrayC++ PythonO(n)O(1)Medium🔒Prefix Sum, Greedy
3517Smallest Palindromic Rearrangement IC++ PythonO(n + 26)O(26)MediumFreq Table, Counting Sort, Greedy
3518Smallest Palindromic Rearrangement IIC++ PythonO(26 * n)O(26)HardFreq Table, Counting Sort, Greedy, Combinatorics
3523Make Array Non-decreasingC++ PythonO(n)O(1)MediumGreedy
3542Minimum Operations to Convert All Elements to ZeroC++ PythonO(n)O(n)MediumGreedy, Mono Stack
3545Minimum Deletions for At Most K Distinct CharactersC++ PythonO(n + 26)O(n + 26)EasyFreq Table, Counting Sort, Greedy
3557Find Maximum Number of Non Intersecting SubstringsC++ PythonO(n)O(26)MediumGreedy, Hash Table
3576Transform Array to All Equal ElementsC++ PythonO(n)O(1)MediumGreedy
3587Minimum Adjacent Swaps to Alternate ParityC++ PythonO(n)O(1)MediumGreedy
3627Maximum Median Sum of Subsequences of Size 3C++ PythonO(nlogn)O(1)MediumSort, Greedy
3630Partition Array for Maximum XOR and ANDC++ PythonO(nlogr * 2^n)O(1)HardBitmasks, Greedy
3633Earliest Finish Time for Land and Water Rides IC++ PythonO(n)O(1)EasyGreedy
3635Earliest Finish Time for Land and Water Rides IIC++ PythonO(n)O(1)MediumGreedy
3638Maximum Balanced ShipmentsC++ PythonO(n)O(1)MediumGreedy
3645Maximum Total from Optimal Activation OrderC++ PythonO(nlogn)O(n)MediumSort, Greedy
3675Minimum Operations to Transform StringC++ PythonO(n)O(1)MediumGreedy
3681Maximum XOR of SubsequencesC++ PythonO(nlogr)O(r)HardBitmasks, Greedy
3689Maximum Total Subarray Value IC++ PythonO(n)O(1)MediumGreedy
3711Maximum Transactions Without Negative BalanceC++ PythonO(nlogn)O(n)Medium🔒Greedy, Heap
3720Lexicographically Smallest Permutation Greater Than TargetC++ PythonO(26 * n)O(26)MediumFreq Table, Greedy
3723Maximize Sum of Squares of DigitsC++ PythonO(n)O(1)MediumGreedy
3724Minimum Operations to Transform ArrayC++ PythonO(n)O(1)MediumGreedy
3727Maximum Alternating Sum of SquaresC++ PythonO(n)O(n)MediumGreedy, Sort, Quick Select
3730Maximum Calories Burnt from JumpsC++ PythonO(nlogn)O(1)Medium🔒Greedy, Sort
3732Maximum Product of Three Elements After One ReplacementC++ PythonO(n)O(1)MediumGreedy
3734Lexicographically Smallest Palindromic Permutation Greater Than TargetC++ PythonO(26 * n)O(26)HardFreq Table, Greedy
3752Lexicographically Smallest Negated Permutation that Sums to TargetC++ PythonO(n)O(1)MediumGreedy, Two Pointers
3763Maximum Total Sum with Threshold ConstraintsC++ PythonO(n)O(n)Medium🔒Sort, Counting Sort, Greedy
3767Maximize Points After Choosing K TasksC++ PythonO(n)O(n)MediumGreedy, Sort, Quick Select
3776Minimum Moves to Balance Circular ArrayC++ PythonO(n)O(1)MediumGreedy
3785Minimum Swaps to Avoid Forbidden ValuesC++ PythonO(n)O(1)HardBoyer–Moore Majority Vote Algorithm, Freq Table, Greedy
3796Find Maximum Value in a Constrained SequenceC++ PythonO(n)O(n)MediumGreedy, DP
3797Count Routes to Climb a Rectangular GridC++ PythonO(n * m)O(m)HardDP, Two Pointers
3806Maximum Bitwise AND After Increment OperationsC++ PythonO(nlogr)O(n)HardBitmasks, Greedy, Sort, Quick Select
3812Minimum Edge Toggles on a TreeC++ PythonO(n)O(n)HardGreedy, Topological Sort, Bitmasks
3816Lexicographically Smallest String After Deleting Duplicate CharactersC++ PythonO(n + 26)O(26)HardFreq Table, Greedy
3828Final Element After Subarray DeletionsC++ PythonO(1)O(1)MediumGreedy, Game Theory
3849Maximum Bitwise XOR After RearrangementC++ PythonO(n)O(1)MediumGreedy
3854Minimum Operations to Make Array Parity AlternatingC++ PythonO(n)O(1)MediumGreedy
3858Minimum Bitwise OR From GridC++ PythonO(nlogr)O(1)MediumBitmasks, Greedy
3863Minimum Operations to Sort a StringC++ PythonO(n)O(1)MediumGreedy
3868Minimum Cost to Equalize Arrays Using SwapsC++ PythonO(n)O(n)MediumFreq Table, Greedy
3888Minimum Operations to Make All Grid Elements EqualC++ PythonO(m * n)O(k * n)Hard🔒Sliding Window, Greedy, Difference Array
3892Minimum Operations to Achieve At Least K PeaksC++ PythonO(n + klogn)O(n)HardGreedy, Heap, Doubly Linked List
3897Maximum Value of Concatenated Binary SegmentsC++ PythonO(r + nlogn)O(r + n)HardGreedy
3914Minimum Operations to Make Array Non DecreasingC++ PythonO(n)O(1)MediumGreedy
3919Minimum Cost to Move Between IndicesC++ PythonO(n)O(n)MediumGreedy, Prefix Sum
3922Minimum Flips to Make Binary String CoherentC++ PythonO(n)O(1)MediumGreedy, Case Works
3947Maximum Number of Items From Sale IIC++ PythonO(nlogn)O(n)MediumFreq Table, Sort, Greedy
3948Lexicographically Maximum MEX ArrayC++ PythonO(n)O(n)HardHash Table, Freq Table, Prefix Sum, Greedy
3952Maximum Total Value of Covered IndicesC++ PythonO(n)O(1)MediumGreedy, DP
3961Maximize Sum of Device RatingsC++ PythonO(m * n)O(1)MediumGreedy

⬆️ Back to Top

Graph

#TitleSolutionTimeSpaceDifficultyTagNote
3108Minimum Cost Walk in Weighted GraphC++ PythonO(n + e + q)O(n)HardUnion Find
3112Minimum Time to Visit Disappearing NodesC++ PythonO(|E| * log|V|)O(|E|)MediumGraph, Dijkstra's Algorithm
3123Find Edges in Shortest PathsC++ PythonO(|E| * log|V|)O(|E|)HardGraph, Dijkstra's Algorithm
3235Check if the Rectangle Corner Is ReachableC++ PythonO(n^2)O(n)HardGraph, BFS, DFS, Union Find
3243Shortest Distance After Road Addition Queries IC++ PythonO(n^2)O(n^2)MediumGraph, Dijkstra's Algorithm, BFS
3244Shortest Distance After Road Addition Queries IIC++ PythonO(nlogn)O(n)HardGraph, BST, Sorted List
3265Count Almost Equal Pairs IC++ PythonO(n * l^2)O(n)MediumFreq Table, Combinatorics, Graph, BFS
3267Count Almost Equal Pairs IIC++ PythonO(n * l^4)O(n)HardFreq Table, Combinatorics, Graph, BFS
3276Select Cells in Grid With Maximum ScoreC++ PythonO(n^2 * max(n, r))O(n * max(n, r))Hardvariant of Maximum Compatibility Score SumHungarian Weighted Bipartite Matching, DP, Bitmasks
3310Remove Methods From ProjectC++ PythonO(n + e)O(n + e)MediumGraph, BFS
3341Find Minimum Time to Reach Last Room IC++ PythonO(n * m * log(n * m))O(n * m)MediumGraph, Dijkstra's Algorithm
3342Find Minimum Time to Reach Last Room IIC++ PythonO(n * m * log(n * m))O(n * m)MediumGraph, Dijkstra's Algorithm
3377Digit Operations to Make Two Integers EqualC++ PythonO(nlogn)O(n)MediumGraph, Number Theory, Linear Sieve of Eratosthenes, Dijkstra's Algorithm
3378Count Connected Components in LCM GraphC++ PythonO(n + tlogt)O(t)HardNumber Theory, Graph, Union Find
3383Minimum Runes to Add to Cast SpellC++ PythonO(n)O(n)Hard🔒Graph, Tarjan's Strongly Connected Components Algorithm, SCC
3376Minimum Time to Break Locks IC++ PythonO(n^3)O(n^2)MediumBitmasks, DP, Graph, Hungarian Weighted Bipartite Matching
3385Minimum Time to Break Locks IIC++ PythonO(n^3)O(n^2)Hard🔒Graph, Hungarian Weighted Bipartite Matching
3387Maximize Amount After Two Days of ConversionsC++ PythonO(n^2)O(n)MediumBellman-Ford Algorithm, BFS
3419Minimize the Maximum Edge Weight of GraphC++ PythonO(nlogn + e)O(n + e)MediumGraph, Dijkstra's Algorithm, Prim's Algorithm, Binary Search, BFS
3435Frequencies of Shortest SupersequencesC++ PythonO(n + k^2 * 2^k)O(k^2)HardBitmasks, Graph, Topological Sort
3481Apply SubstitutionsC++ PythonO(r * 2^r)O(r * 2^r)Medium🔒Graph, Topological Sort, Memoization
3493Properties GraphC++ PythonO(n^2 * m)O(n)MediumGraph, Flood Fill, BFS, Union Find
3532Path Existence Queries in a Graph IC++ PythonO(n + q)O(n)MediumPrefix Sum
3534Path Existence Queries in a Graph IIC++ PythonO((n + q) * logn)O(nlogn)HardPrefix Sum, Greedy, Binary Lifting
3536Maximum Product of Two DigitsC++ PythonO(d + 10)O(10)EasyFreq Table, Greedy
3547Maximum Sum of Edge Values in a GraphC++ PythonO(n)O(n)HardFlood Fill, BFS, Counting Sort, Greedy
3594Minimum Time to Transport All IndividualsC++ PythonO(m * 3^n * log(m * 3^n))O(m * 3^n)HardGraph, Dijkstra's Algorithm, Submask Enumeration
3600Maximize Spanning Tree Stability with UpgradesC++ PythonO(n + eloge)O(n)HardMST, Maximum Spanning Tree, Union Find, Kruskal's Algorithm, Greedy
3604Minimum Time to Reach Destination in Directed GraphC++ PythonO(n + elogn)O(n + e)MediumGraph, Dijkstra's Algorithm
3620Network Recovery PathwaysC++ PythonO((n + e) * logr)O(n + e)HardBinary Search, Topological Sort, DP
3650Minimum Cost Path with Edge ReversalsC++ PythonO(n + elogn)O(n + e)MediumGraph, Dijkstra's Algorithm
3656Determine if a Simple Graph ExistsC++ PythonO(nlogn)O(1)Medium🔒Graph, Erdős–Gallai Theorem, Sort, Prefix sum, Two Pointers
3660Jump Game IXC++ PythonO(n)O(1)MediumGraph, Prefix Sum
3710Maximum Partition FactorC++ PythonO(n^2 * logn)O(n^2)HardGraph, Sort, Coordinate Compression, Binary Search, BFS, Greedy, Union Find
3778Minimum Distance Excluding One Maximum Weighted EdgeC++ PythonO(n + elogn)O(n + e)Medium🔒Graph, Dijkstra's Algorithm
3873Maximum Points Activated with One AdditionC++ PythonO(n)O(n)HardGraph, Union Find
3887Incremental Even-Weighted Cycle QueriesC++ PythonO(n + e)O(n)HardGraph, Union Find
3910Count Connected Subgraphs with Even Node SumC++ PythonO((n + e) * 2^n)O(n + e)HardGraph, Bitmask, DFS
3928Minimum Cost to Buy Apples IIC++ PythonO(n * (n + elogn))O(n + e)HardGraph, Dijkstra's Algorithm

⬆️ Back to Top

Geometry

#TitleSolutionTimeSpaceDifficultyTagNote
3453Separate Squares IC++ PythonO(nlogn)O(n)MediumBinary Search, Sort, Line Sweep
3454Separate Squares IIC++ PythonO(nlogn)O(n)HardSort, Line Sweep, Segment Tree

⬆️ Back to Top

Simulation

#TitleSolutionTimeSpaceDifficultyTagNote
3100Water Bottles IIC++ PythonO(sqrt(n))O(1)MediumSimulation
3168Minimum Number of Chairs in a Waiting RoomC++ PythonO(n)O(1)EasySimulation
3175Find The First Player to win K Games in a RowC++ PythonO(n)O(1)MediumSimulation
3248Snake in MatrixC++ PythonO(c)O(1)MediumSimulation
3412Find Mirror Score of a StringC++ PythonO(n + 26)O(n + 26)MediumSimulation, Hash Table, Stack
3433Count Mentions Per UserC++ PythonO(eloge + e * n)O(e + n)MediumSimulation
3507Minimum Pair Removal to Sort Array IC++ PythonO(nlogn)O(n)EasySimulation, Doubly Linked List, Sorted List, BST
3510Minimum Pair Removal to Sort Array IIC++ PythonO(nlogn)O(n)HardSimulation, Doubly Linked List, Sorted List, BST
3522Calculate Score After Performing InstructionsC++ PythonO(n)O(n)MediumSimulation
3561Resulting String After Adjacent RemovalsC++ PythonO(n)O(1)MediumSimulation, Stack
3597Partition StringC++ PythonO(n)O(t)MediumSimulation, Trie
3608Minimum Time for K Connected ComponentsC++ PythonO(n + eloge)O(n)MediumBackward Simulation, Sort, Union Find
3609Minimum Moves to Reach Target in GridC++ PythonO(logtx + logty)O(1)HardBackward Simulation
3612Process String with Special Operations IC++ PythonO(r)O(r)MediumSimulation, Deque
3613Minimize Maximum Component CostC++ PythonO(n + eloge)O(n)MediumBackward Simulation, Sort, Union Find
3614Process String with Special Operations IIC++ PythonO(n)O(1)HardBackward Simulation
3616Number of Student ReplacementsC++ PythonO(n)O(1)Medium🔒Simulation
3639Minimum Time to Activate StringC++ PythonO(n)O(n)MediumBackward Simulation, Doubly Linked List
3792Sum of Increasing Product BlocksC++ PythonO(n^2)O(n^2)Medium🔒Simulation, Math
3847Find the Score Difference in a GameC++ PythonO(n)O(1)MediumSimulation
3853Merge Close CharactersC++ PythonO(n + 26)O(26)MediumSimulation, Freq Table, Two Pointers, Sliding Window
3867Sum of GCD of Formed PairsC++ PythonO(nlogr)O(n)MediumSimulation, Prefix sum, Sort, Two Pointers
3894Traffic Signal ColorC++ PythonO(1)O(1)EasySimulation

⬆️ Back to Top

Constructive Algorithms

#TitleSolutionTimeSpaceDifficultyTagNote
3139Minimum Cost to Equalize ArrayC++ PythonO(n)O(1)HardConstructive Algorithms, Math
3260Find the Largest Palindrome Divisible by KC++ PythonO(n)O(1)HardString, Constructive Algorithms, Math
3311Construct 2D Grid Matching Graph LayoutC++ PythonO(n)O(n)HardGraph, Constructive Algorithms, BFS
3375Minimum Operations to Make Array Values Equal to KC++ PythonO(n)O(n)EasyHash Table, Constructive Algorithms
3680Generate ScheduleC++ PythonO(n^2)O(1)MediumConstructive Algorithms
3875Construct Uniform Parity Array IC++ PythonO(1)O(1)EasyConstructive Algorithms
3876Construct Uniform Parity Array IIC++ PythonO(n)O(1)MediumConstructive Algorithms

⬆️ Back to Top

Design

#TitleSolutionTimeSpaceDifficultyTagNote
3242Design Neighbor Sum ServiceC++ Pythonctor: O(n^2)
adjacentSum: O(1)
diagonalSum: O(1)
O(n^2)EasyHash Table
3369Design an Array Statistics TrackerC++ Pythonctor: O(1)
addNumber: O(logn)
removeFirstAddedNumber: O(logn)
getMean: O(1)
getMedian: O(1)
getMode: O(1)
O(n)Hard🔒Deque, Freq Table, Sorted List, BST
3391Design a 3D Binary Matrix with Efficient Layer TrackingC++ Pythonctor: O(1)
setCell: O(logn)
unsetCell: O(logn)
largestMatrix: O(logn)
O(n^3)Medium🔒Heap, Sorted List
3408Design Task ManagerC++ Pythonctor: O(tlogt)
add: O(logt)
edit: O(logt)
rmv: O(logt)
execTop: O(logt)
O(t)MediumSorted List
3484Design SpreadsheetC++ Pythonctor: O(1)
setCell: O(1)
resetCell: O(1)
getValue: O(1)
O(n)MediumHash Table
3508Implement RouterC++ Pythonctor: O(1)
addPacket: O(logn)
forwardPacket: O(logn)
getCount: O(logn)
O(n)MediumQueue, Sorted List, Ordered Set
3709Design Exam Scores TrackerC++ Pythonctor: O(1)
record: O(1)
totalScore: O(logn)
O(n)MediumPrefix Sum, Binary Search
3815Design Auction SystemC++ Pythonctor: O(1)
addBid: O(logn)
updateBid: O(logn)
removeBid: O(logn)
getHighestBidder: O(1)
O(n)MediumHash Table, Heap, Sorted List, BST
3822Design Order Management SystemC++ Pythonctor: O(1)
addOrder: O(1)
modifyOrder: O(1)
cancelOrder: O(1)
getOrdersAtPrice: O(n)
O(n)Medium🔒Hash Table
3829Design Ride Sharing SystemC++ Pythonctor: O(1)
addRider: O(1)
addDriver: O(1)
matchDriverWithRider: O(1)
cancelRider: O(1)
O(n)MediumOrdered Dict
3885Design Event ManagerC++ Pythonctor: O(n)
updatePriority: O(logn)
pollHightest: O(logn)
O(n)MediumSorted List, BST, Heap, Hash Table

⬆️ Back to Top

JS

#TitleSolutionTimeSpaceDifficultyTagNote

⬆️ Back to Top

SQL

#TitleSolutionTimeSpaceDifficultyTagNote
3050Pizza Toppings Cost AnalysisMySQLO(n^3 * logn)O(n^3)Medium🔒
3051Find Candidates for Data Scientist PositionMySQLO(nlogn)O(n)Easy🔒
3052Maximize ItemsMySQLO(n)O(n)Hard🔒
3053Classifying Triangles by LengthsMySQLO(n)O(n)Easy🔒
3054Binary Tree NodesMySQLO(nlogn)O(n)Medium🔒
3055Top Percentile FraudMySQLO(nlogn)O(n)Medium🔒
3056Snaps AnalysisMySQLO(n)O(n)Medium🔒
3057Employees Project AllocationMySQLO(nlogn)O(n)Hard🔒
3058Friends With No Mutual FriendsMySQLO(n^2 * logn)O(n^2)Medium🔒
3059Find All Unique Email DomainsMySQLO(nlogn)O(n)Easy🔒
3060User Activities within Time BoundsMySQLO(nlogn)O(n)Hard🔒
3061Calculate Trapping Rain WaterMySQLO(nlogn)O(n)Hard🔒
3087Find Trending HashtagsMySQLO(nlogn)O(n)Medium🔒
3089Find Bursty BehaviorMySQLO(nlogn)O(n)Medium🔒Window Function
3103Find Trending Hashtags IIMySQLO(n * l^2 + (n * l) * log(n * l))O(n * l^2)Hard🔒Recursive CTE
3118Friday Purchase IIIMySQLO(n)O(n)Medium🔒
3124Find Longest CallsMySQLO(nlogn)O(n)Medium🔒Window Function
3126Server Utilization TimeMySQLO(nlogn)O(n)MediumWindow Function
3140Consecutive Available Seats IIMySQLO(nlogn)O(n)Medium🔒Window Function
3150Invalid Tweets IIMySQLO(n * l + nlogn)O(n * l)Easy🔒String
3156Employee Task Duration and Concurrent TasksMySQLO(nlogn)O(n)Hard🔒Line Sweep
3166Calculate Parking Fees and DurationMySQLO(nlogn)O(n)Medium🔒
3172Second Day VerificationMySQLO(nlogn)O(n)Easy🔒
3182Find Top Scoring StudentsMySQLO(nlogn)O(n)Medium🔒
3188Find Top Scoring Students IIMySQLO(nlogn)O(n)Hard🔒
3198Find Cities in Each StateMySQLO(nlogn)O(n)Easy🔒
3204Bitwise User Permissions AnalysisMySQLO(n)O(n)Medium🔒
3214Year on Year Growth RateMySQLO(nlogn)O(n)Hard🔒Window Function
3220Odd and Even TransactionsMySQLO(nlogn)O(n)Medium
3230Customer Purchasing Behavior AnalysisMySQLO(nlogn)O(n)Medium🔒Window Function
3236CEO Subordinate HierarchyMySQLO(nlogn)O(n)Hard🔒Recursive CTE, BFS
3246Premier League Table RankingMySQLO(nlogn)O(n)Easy🔒Window Function
3252Premier League Table Ranking IIMySQLO(nlogn)O(n)Medium🔒Window Function
3262Find Overlapping ShiftsMySQLO(nlogn)O(n)Medium🔒Line Sweep
3268Find Overlapping Shifts IIMySQLO(n^2)O(n^2)Hard🔒Line Sweep, Window Function, Combinatorics
3278Find Candidates for Data Scientist Position IIMySQLO(p * s * n + p * nlogn + plogp)O(p * s * n)Medium🔒Window Function
3293Calculate Product Final PriceMySQLO(nlogn)O(n)Medium🔒
3308Find Top Performing DriverMySQLO(tlogt)O(t)Medium🔒Window Function
3322Premier League Table Ranking IIIMySQLO(nlogn)O(n)Medium🔒Window Function
3328Find Cities in Each State IIMySQLO(nlogn)O(n)Medium🔒
3338Second Highest Salary IIMySQLO(nlogn)O(n)Medium🔒Window Function
3358Books with NULL RatingsMySQLO(nlogn)O(n)Easy🔒
3368First Letter CapitalizationMySQLO(n * l^2 + (n * l) * log(n * l))O(n * l^2)Hard🔒Recursive CTE
3374First Letter Capitalization IIMySQLO(n * l^2 + (n * l) * log(n * l))O(n * l^2)Hard🔒Recursive CTE
3384Team Dominance by Pass SuccessMySQLO(plogp + t)O(p + t)Hard🔒
3390Longest Team Pass StreakMySQLO(plogp + t)O(p + t)Hard🔒Recursive CTE, Window Function
3401Find Circular Gift Exchange ChainsMySQLO(n^2)O(n^2)Hard🔒Recursive CTE, Window Function
3415Find Products with Three Consecutive DigitsMySQLO(nlogn)O(n)Easy🔒Regular Expression
3421Find Students Who ImprovedMySQLO(nlogn)O(n)Medium🔒Window Function
3436Find Valid EmailsMySQLO(n)O(n)EasyRegular Expression
3451Find Invalid IP AddressesMySQLO(nlogn)O(n)HardRegular Expression
3465Find Products with Valid Serial NumbersMySQLO(nlogn)O(n)EasyRegular Expression
3475DNA Pattern RecognitionMySQLO(nlogn)O(n)MediumRegular Expression
3482Analyze Organization HierarchyMySQLO(n^2)O(n^2)HardRecursive CTE, BFS
3497Analyze Subscription ConversionMySQLO(nlogn)O(n)Medium
3521Find Product Recommendation PairsMySQLO(n^2 * logn)O(n^2)Medium
3554Find Category Recommendation PairsMySQLO(n^2 * logn)O(n^2)Hard
3564Seasonal Sales AnalysisMySQLO(nlogn)O(n)MediumWindow Function
3570Find Books with No Available CopiesMySQLO(nlogn)O(n)Easy
3580Find Consistently Improving EmployeesMySQLO(nlogn)O(n)MediumWindow Function
3586Find COVID Recovery PatientsMySQLO(n^2)O(n^2)Medium
3601Find Drivers with Improved Fuel EfficiencyMySQLO(nlogn)O(n)Medium
3611Find Overbooked EmployeesMySQLO(m + nlogn)O(m + n)Medium
3617Find Students with Study Spiral PatternMySQLO(nlogn)O(n)HardWindow Function
3626Find Stores with Inventory ImbalanceMySQLO(n^2 * logn)O(n^2)Medium
3642Find Books with Polarized OpinionsMySQLO(r + nlogn)O(r + n)Easy
3657Find Loyal CustomersMySQLO(nlogn)O(n)Medium
3673Find Zombie SessionsMySQLO(nlogn)O(n)Hard
3705Find Golden Hour CustomersMySQLO(nlogn)O(n)Medium
3716Find Churn Risk CustomersMySQLO(nlogn)O(n)MediumWindow Function
3764Most Common Course PairsMySQLO(nlogn)O(n)HardWindow Function
3793Find Users with High Token UsageMySQLO(nlogn)O(n)Easy
3808Find Emotionally Consistent UsersMySQLO(nlogn)O(n)MediumWindow Function
3832Find Users with Persistent Behavior PatternsMySQLO(nlogn)O(n)HardWindow Function

⬆️ Back to Top

PD

#TitleSolutionTimeSpaceDifficultyTagNote

⬆️ Back to Top