Skip to content

πŸ‹οΈ Python / Modern C++ Solutions of All 3836 LeetCode Problems (Weekly Update)

License

Notifications You must be signed in to change notification settings

kamyu104/LeetCode-Solutions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

20,161 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

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

# Title Solution Time Space Difficulty Tag Note
3064 Guess the Number Using Bitwise Questions I C++ Python O(logn) O(1) Medium πŸ”’ Bit Manipulation
3094 Guess the Number Using Bitwise Questions II C++ Python O(logr) O(1) Medium πŸ”’ Bit Manipulation
3125 Maximum Number That Makes Result of Bitwise AND Zero C++ Python O(1) O(1) Medium πŸ”’ Bit Manipulation
3133 Minimum Array End C++ Python O(logn) O(1) Medium Bit Manipulation
3199 Count Triplets with Even XOR Set Bits I C++ Python O(nlogr) O(1) Easy πŸ”’ Brute Force, Bit Manipulation, Parity
3215 Count Triplets with Even XOR Set Bits II C++ Python O(nlogr) O(1) Medium πŸ”’ Bit Manipulation, Parity
3226 Number of Bit Changes to Make Two Integers Equal C++ Python O(logn) O(1) Easy Bit Manipulation
3289 The Two Sneaky Numbers of Digitville C++ Python O(n) O(1) Easy Bit Manipulation
3304 Find the K-th Character in String Game I C++ Python O(n) O(1) Easy Bitmasks
3307 Find the K-th Character in String Game II C++ Python O(1) O(1) Hard Bitmasks
3314 Construct the Minimum Bitwise Array I C++ Python O(n) O(1) Easy Bit Manipulation
3315 Construct the Minimum Bitwise Array II C++ Python O(n) O(1) Medium Bit Manipulation
3344 Maximum Sized Array C++ Python precompute: O(max_s^(1/5) * log(max_s))
runtime: O(log(max_s))
O(max_s^(1/5)) Medium πŸ”’ Precompute, Bitmasks, Combinatorics, Binary Search
3370 Smallest Number With All Set Bits C++ Python O(1) O(1) Easy Bit Manipulation
3566 Partition Array into Two Equal Product Subsets C++ Python O(n * 2^n) O(1) Medium Bitmasks
3632 Subarrays with XOR at Least K C++ Python O(nlogr) O(t) Hard πŸ”’ Bitmasks, Prefix Sum, Trie
3646 Next Special Palindrome Number C++ Python precompute: O(9 * 2^9 + 16 * p + plogp)
runtime: O(logp)
O(p) Hard Precompute, Bitmasks, Sort, Binary Search
3702 Longest Subsequence With Non-Zero Bitwise XOR C++ Python O(n) O(1) Medium Bitmasks
3750 Minimum Number of Flips to Reverse Binary String C++ Python O(logn) O(1) Easy Bitmasks
3766 Minimum Operations to Make Binary Palindrome C++ Python precompute: O(sqrt(r) * logr)
runtime: O(r)
O(r) Medium Precompute, Bitmasks, Two Pointers
3769 Sort Integers by Binary Reflection C++ Python O(nlogr + nlogn) O(n) Easy Sort, Bitmasks
3782 Last Remaining Integer After Alternating Deletion Operations C++ Python O(1) O(1) Hard Bitmasks, Simulation
3827 Count Monobit Integers C++ Python O(logn) O(1) Easy Bitmasks


Array

# Title Solution Time Space Difficulty Tag Note
3009 Maximum Number of Intersections on the Chart C++ Python O(nlogn) O(n) Hard πŸ”’ Sort, Line Sweep, Coordinate Compression
3010 Divide an Array Into Subarrays With Minimum Cost I C++ Python O(n) O(1) Easy Array, Quick Select
3015 Count the Number of Houses at a Certain Distance I C++ Python O(n) O(n) Medium Math, Prefix Sum, Difference Array
3017 Count the Number of Houses at a Certain Distance II C++ Python O(n) O(1) Hard Math, Prefix Sum, Difference Array
3026 Maximum Good Subarray Sum C++ Python O(n) O(n) Medium Prefix Sum
3028 Ant on the Boundary C++ Python O(n) O(1) Easy Prefix Sum
3030 Find the Grid of Region Average C++ Python O(m * n) O(m * n) Medium Array
3033 Modify the Matrix C++ Python O(m * n) O(1) Easy Array
3038 Maximum Number of Operations With the Same Score I C++ Python O(n) O(1) Easy Array
3065 Minimum Operations to Exceed Threshold Value I C++ Python O(n) O(1) Easy Array
3069 Distribute Elements Into Two Arrays I C++ Python O(n) O(n) Easy Array
3070 Count Submatrices with Top-Left Element and Sum Less Than k C++ Python O(n * m) O(1) Medium Array, Prefix Sum
3071 Minimum Operations to Write the Letter Y on a Grid C++ Python O(n^2) O(1) Medium Array
3079 Find the Sum of Encrypted Integers C++ Python O(nlogr) O(1) Easy Array
3096 Minimum Levels to Gain More Points C++ Python O(n) O(n) Medium Prefix Sum
3105 Longest Strictly Increasing or Strictly Decreasing Subarray C++ Python O(n) O(1) Easy Array
3127 Make a Square with the Same Color C++ Python O((n - w + 1)^2 * w^2) O(1) Easy Array
3131 Find the Integer Added to Array I C++ Python O(n) O(1) Easy Array
3142 Check if Grid Satisfies Conditions C++ Python O(m * n) O(1) Easy Array
3147 Taking Maximum Energy From the Mystic Dungeon C++ Python O(n) O(1) Medium Array
3151 Special Array I C++ Python O(n) O(1) Easy Array
3152 Special Array II C++ Python O(n + q) O(n) Medium Prefix Sum
3153 Sum of Digit Differences of All Pairs C++ Python O(nlogr) O(10 * logr) Medium Prefix Sum
3159 Find Occurrences of an Element in an Array C++ Python O(n + q) O(n) Medium Array
3173 Bitwise OR of Adjacent Elements C++ Python O(n) O(1) Easy πŸ”’ Array
3187 Peaks in Array C++ Python O(n + qlogn) O(n) Hard BIT, Fenwick Tree
3195 Find the Minimum Area to Cover All Ones I C++ Python O(n * m) O(1) Medium Array
3224 Minimum Array Changes to Make Differences Equal C++ Python O(n + k) O(k) Medium Prefix Sum, Difference Array
3279 Maximum Total Area Occupied by Pistons C++ Python O(h) O(h) Hard πŸ”’ Line Sweep, Difference Array
3285 Find Indices of Stable Mountains C++ Python O(n) O(1) Easy Array
3300 Minimum Element After Replacement With Digit Sum C++ Python O(nlogr) O(1) Easy Array
3330 Find the Original Typed String I C++ Python O(n) O(1) Easy Array
3334 Find the Maximum Factor Score of Array C++ Python O(nlogr) O(n) Medium Prefix Sum
3349 Adjacent Increasing Subarrays Detection I C++ Python O(n) O(1) Easy Array
3350 Adjacent Increasing Subarrays Detection II C++ Python O(n) O(1) Medium Array
3353 Minimum Total Operations C++ Python O(n) O(1) Easy πŸ”’ Array
3354 Make Array Elements Equal to Zero C++ Python O(n) O(n) Easy CodeChef Starters 146 - Bouncing Ball Prefix Sum
3355 Zero Array Transformation I C++ Python O(n + q) O(n) Medium Line Sweep
3361 Shift Distance Between Two Strings C++ Python O(n + 26) O(26) Medium Prefix Sum
3379 Transformed Array C++ Python O(n) O(1) Easy Array
3380 Maximum Area Rectangle With Point Constraints I C++ Python O(nlogn) O(n) Medium Sort, Brute Force, BIT, Fenwick Tree, Hash Table
3382 Maximum Area Rectangle With Point Constraints II C++ Python O(nlogn) O(n) Hard Sort, BIT, Fenwick Tree, Hash Table
3386 Button with Longest Push Time C++ Python O(n) O(1) Easy Array
3392 Count Subarrays of Length Three With a Condition C++ Python O(n) O(1) Easy Array
3400 Maximum Number of Matching Indices After Right Shifts C++ Python O(n^2) O(1) Medium πŸ”’ Brute Force
3417 Zigzag Grid Traversal With Skip C++ Python O(n * m) O(1) Easy Array
3423 Maximum Difference Between Adjacent Elements in a Circular Array C++ Python O(n) O(1) Easy Array
3427 Sum of Variable Length Subarrays C++ Python O(n) O(n) Easy Difference Array
3432 Count Partitions with Even Sum Difference C++ Python O(n) O(1) Easy Prefix Sum
3440 Reschedule Meetings for Maximum Free Time II C++ Python O(n) O(1) Medium Array
3446 Sort Matrix by Diagonals C++ Python O(n^2 * logn) O(n^2) Medium Array, Sort
3452 Sum of Good Numbers C++ Python O(n) O(1) Easy Array
3467 Transform Array by Parity C++ Python O(n) O(1) Easy Array
3502 Minimum Cost to Reach Every Position C++ Python O(n) O(1) Easy Prefix Sum
3514 Number of Unique XOR Triplets II C++ Python O(nlogn) O(n) Medium Fast Walsh–Hadamard Transform, FWHT, Fast Subset Transform, FST, Hash Table
3531 Count Covered Buildings C++ Python O(n) O(n) Medium Array
3537 Fill a Special Grid C++ Python O(4^n) O(1) Medium Divide and Conquer, Array
3540 Minimum Time to Visit All Houses C++ Python O(n + q) O(n) Medium πŸ”’ Prefix Sum
3546 Equal Sum Grid Partition I C++ Python O(m * n) O(1) Medium Array
3548 Equal Sum Grid Partition II C++ Python O(m * n) O(m * n) Hard Array, Hash Table
3549 Multiply Two Polynomials C++ Python O((n + m) * log(n + m)) O(n + m) Hard πŸ”’ Fast Fourier Transform, FFT
3550 Smallest Index With Digit Sum Equal to Index C++ Python O(nlogr) O(1) Easy Array
3569 Maximize Count of Distinct Primes After Split C++ Python O(r + nlogn + qlogn) O(r + n) Medium Number Theory, BST, Sorted List, Segment Tree
3637 Trionic Array I C++ Python O(n) O(1) Easy Array
3643 Flip Square Submatrix Vertically C++ Python O(k^2) O(1) Easy Array
3653 XOR After Range Multiplication Queries I C++ Python O(qlogm + (q + n) * sqrt(n)) O(n * sqrt(n)) Medium Sqrt Decomposition, Difference Array, Fast Exponentiation, Simulation
3655 XOR After Range Multiplication Queries II C++ Python O(qlogm + (q + n) * sqrt(n)) O(n * sqrt(n)) Hard Sqrt Decomposition, Difference Array, Fast Exponentiation
3674 Minimum Operations to Equalize Array C++ Python O(n) O(1) Easy Array
3683 Earliest Time to Finish One Task C++ Python O(n) O(1) Easy Array
3687 Library Late Fee Calculator C++ Python O(n) O(1) Easy πŸ”’ Array
3688 Bitwise OR of Even Numbers in an Array C++ Python O(n) O(1) Easy Array
3696 Maximum Distance Between Unequal Words in Array I C++ Python O(n * l) O(1) Easy πŸ”’ Array
3700 Number of ZigZag Arrays II C++ Python O((r - l)^3 * logn) O((r - l)^2) Hard Matrix Exponentiation
3701 Compute Alternating Sum C++ Python O(n) O(1) Easy Array
3706 Maximum Distance Between Unequal Words in Array II C++ Python O(n * l) O(1) Medium πŸ”’ Array
3707 Equal Score Substrings C++ Python O(n) O(1) Easy Array, Prefix Sum
3708 Longest Fibonacci Subarray C++ Python O(n) O(1) Medium Array
3719 Longest Balanced Subarray I C++ Python O(nlogn) O(n) Medium Brute Force, Segment Tree, Binary Search, Prefix Sum
3721 Longest Balanced Subarray II C++ Python O(nlogn) O(n) Hard Segment Tree, Binary Search, Prefix Sum
3736 Minimum Moves to Equal Array Elements III C++ Python O(n) O(1) Easy Array
3737 Count Subarrays With Majority Element I C++ Python O(n) O(n) Medium Freq Table, Prefix Sum
3738 Longest Non-Decreasing Subarray After Replacing at Most One Element C++ Python O(n) O(n) Medium Array, Prefix Sum
3739 Count Subarrays With Majority Element II C++ Python O(n) O(n) Hard Freq Table, Prefix Sum
3751 Total Waviness of Numbers in Range I C++ Python O(nlogn) O(logn) Medium Brute Force
3756 Concatenate Non-Zero Digits and Multiply by Sum II C++ Python O(n) O(n) Medium Prefix Sum
3762 Minimum Operations to Equalize Subarrays C++ Python O((n + q) * logn) O(nlogn) Hard Prefix Sum, Coordinate Compression, Persistent Segment Tree, Binary Search
3774 Absolute Difference Between Maximum and Minimum K Elements C++ Python O(n) O(1) Easy Sort, Quick Select
3788 Maximum Score of a Split C++ Python O(n) O(1) Medium Prefix Sum
3809 Best Reachable Tower C++ Python O(n) O(1) Medium Array
3814 Maximum Capacity Within Budget C++ Python O(n + b) O(b) Medium Hash Table, Prefix Sum, Sort, Mono Stack, Binary Search
3818 Minimum Prefix Removal to Make Array Strictly Increasing C++ Python O(n) O(1) Medium Array
3819 Rotate Non Negative Elements C++ Python O(n) O(n) Medium Array
3833 Count Dominant Indices C++ Python O(n) O(1) Easy Array


String

# Title Solution Time Space Difficulty Tag Note
3019 Number of Changing Keys C++ Python O(n) O(1) Easy String
3023 Find Pattern in Infinite Stream I C++ Python O(p + n) O(p) Medium πŸ”’ String, KMP Algorithm
3029 Minimum Time to Revert Word to Initial State I C++ Python O(n) O(n) Medium String, Z-Function, Brute Force
3031 Minimum Time to Revert Word to Initial State II C++ Python O(n) O(n) Hard String, Z-Function
3034 Number of Subarrays That Match a Pattern I C++ Python O(n) O(m) Medium Brute Force, String, KMP Algorithm
3036 Number of Subarrays That Match a Pattern II C++ Python O(n) O(m) Hard String, KMP Algorithm
3037 Find Pattern in Infinite Stream II C++ Python O(p + n) O(p) Hard πŸ”’ String, KMP Algorithm
3042 Count Prefix and Suffix Pairs I C++ Python O(n * l) O(t) Easy Trie, Brute Force
3043 Find the Length of the Longest Common Prefix C++ Python O((n + m) * l) O(t) Medium Trie, Hash Table
3045 Count Prefix and Suffix Pairs II C++ Python O(n * l) O(t) Hard Trie
3076 Shortest Uncommon Substring in an Array C++ Python O(n * l^2) O(t) Medium Trie
3093 Longest Common Suffix Queries C++ Python O((n + q) * l) O(t) Hard Trie
3110 Score of a String C++ Python O(n) O(1) Easy String
3136 Valid Word C++ Python O(n) O(1) Easy String
3163 String Compression III C++ Python O(n) O(1) Medium String
3210 Find the Encrypted String C++ Python O(n) O(1) Medium String
3271 Hash Divided String C++ Python O(n) O(1) Medium String
3280 Convert Date to Binary C++ Python O(1) O(1) Easy String
3303 Find the Occurrence of First Almost Equal Substring C++ Python O(n + m) O(n + m) Hard Z-Function
3324 Find the Sequence of Strings Appeared on the Screen C++ Python O(n^2) O(1) Medium String
3340 Check Balanced String C++ Python O(n) O(1) Easy String
3407 Substring Matching Pattern C++ Python O(n + m) O(m) Easy String, KMP Algorithm
3455 Shortest Matching Substring C++ Python O(n + m) O(n + m) Hard String, KMP Algorithm, Two Pointers
3456 Find Special Substring of Length K C++ Python O(n) O(1) Easy String
3491 Phone Number Prefix C++ Python O(l * nlogn) O(1) Easy πŸ”’ Trie, Sort
3498 Reverse Degree of a String C++ Python O(n) O(1) Easy String
3529 Count Cells in Overlapping Horizontal and Vertical Substrings C++ Python O(n * m) O(n * m) Medium Z-Function
3571 Find the Shortest Superstring II C++ Python O(n + m) O(n + m) Easy πŸ”’ KMP Algorithm
3582 Generate Tag for Video Caption C++ Python O(n) O(1) Easy String
3598 Longest Common Prefix Between Adjacent Strings After Removals C++ Python O(n * l) O(n) Medium LCP, Prefix Sum
3606 Coupon Code Validator C++ Python O(l * nlogn) O(n * l) Easy Hash Table, Sort
3744 Find Kth Character in Expanded String C++ Python O(n) O(1) Medium πŸ”’ String
3746 Minimum String Length After Balanced Removals C++ Python O(n) O(1) Medium String
3748 Count Stable Subarrays C++ Python O(n + q) O(n) Hard Prefix Sum
3758 Convert Number Words to Digits C++ Python O(n) O(1) Medium πŸ”’ String
3775 Reverse Words With Same Vowel Count C++ Python O(n) O(1) Medium String, Inplace
3777 Minimum Deletions to Make Alternating Substring C++ Python O((n + q) * logn) O(n) Hard BIT, Fenwick Tree
3794 Reverse String Prefix C++ Python O(n) O(1) Easy String
3813 Vowel-Consonant Score C++ Python O(n) O(1) Easy String
3823 Reverse Letters Then Special Characters in a String C++ Python O(n) O(1) Easy String


Linked List

# Title Solution Time Space Difficulty Tag Note
3062 Winner of the Linked List Game C++ Python O(n) O(1) Easy πŸ”’ Linked List
3063 Linked List Frequency C++ Python O(n) O(1) Medium πŸ”’ Linked List
3217 Delete Nodes From Linked List Present in Array C++ Python O(n) O(m) Medium Hash Table, Linked List
3263 Convert Doubly Linked List to Array I C++ Python O(n) O(1) Easy πŸ”’ Linked List
3294 Convert Doubly Linked List to Array II C++ Python O(n) O(1) Medium πŸ”’ Linked List


Stack

# Title Solution Time Space Difficulty Tag Note
3113 Find the Number of Subarrays Where Boundary Elements Are Maximum C++ Python O(n) O(n) Hard Mono Stack, Combinatorics
3174 Clear Digits C++ Python O(n) O(1) Easy Stack, Two Pointers
3676 Count Bowl Subarrays C++ Python O(n) O(n) Medium Mono Stack
3703 Remove K-Balanced Substrings C++ Python O(n) O(n) Medium Stack
3749 Evaluate Valid Expressions C++ Python O(n) O(n) Hard πŸ”’ Stack
3834 Merge Adjacent Equal Elements C++ Python O(n) O(1) Medium Stack, Simulation


Queue

# Title Solution Time Space Difficulty Tag Note


Binary Heap

# Title Solution Time Space Difficulty Tag Note
3066 Minimum Operations to Exceed Threshold Value II C++ Python O(nlogn) O(n) Medium Simulation, Heap
3080 Mark Elements on Array by Performing Queries C++ Python O(q + nlogn) O(n) Medium Hash Table, Heap
3092 Most Frequent IDs C++ Python O(nlogn) O(n) Medium Heap, BST, Sorted List
3256 Maximum Value Sum by Placing Three Rooks I C++ Python O(m * n) O(m + n) Hard Heap, Brute Force
3257 Maximum Value Sum by Placing Three Rooks II C++ Python O(m * n) O(m + n) Hard Heap, Brute Force
3275 K-th Nearest Obstacle Queries C++ Python O(qlogk) O(k) Medium Heap
3684 Maximize Sum of At Most K Distinct Elements C++ Python O(nlogk) O(k) Easy Heap, Sort
3691 Maximum Total Subarray Value II C++ Python O((n + k) * logn) O(n) Hard Heap, Sort, Two Pointers, RMQ, Sparse Table, Segment Tree
3781 Maximum Score After Binary Swaps C++ Python O(nlogn) O(n) Medium Heap


Tree

# Title Solution Time Space Difficulty Tag Note
3109 Find the Index of Permutation C++ Python O(nlogn) O(n) πŸ”’, Medium variant of Count of Smaller Numbers After Self BIT, Fenwick Tree, Combinatorics
3515 Shortest Path in a Weighted Tree C++ Python O(nlogn) O(n) Hard BIT, Fenwick Tree, DFS
3553 Minimum Weighted Subgraph With the Required Paths II C++ Python O(n + q) O(n + q) Hard Tree, DFS, Tarjan's Offline LCA Algorithm
3558 Number of Ways to Assign Edge Weights I C++ Python O(n) O(n) Medium Tree, BFS, Combinatorics
3559 Number of Ways to Assign Edge Weights II C++ Python O(n + q) O(n + q) Medium Tree, DFS, Tarjan's Offline LCA Algorithm, Combinatorics
3585 Find Weighted Median Node in Tree C++ Python O(n + qlogh) O(n + q) Hard Tree, DFS, Tarjan's Offline LCA Algorithm, Binary Search, Prefix Sum
3715 Sum of Perfect Square Ancestors C++ Python precompute: O(r)
runtime: O(nlogx)
O(r + n) Hard Tree, Number Theory, Linear Sieve of Eratosthenes, Freq Table, DFS


Hash Table

# Title Solution Time Space Difficulty Tag Note
3005 Count Elements With Maximum Frequency C++ Python O(n) O(n) Easy Freq Table
3039 Apply Operations to Make String Empty C++ Python O(n) O(1) Medium Freq Table
3044 Most Frequent Prime C++ Python precompute: O(10^MAX_N_M)
runtime: O(n * m * (n + m))
O(10^MAX_N_M + n * m * (n + m)) Medium Number Theory, Linear Sieve of Eratosthenes, Freq Table
3046 Split the Array C++ Python O(n) O(n) Easy Freq Table
3078 Match Alphanumerical Pattern in Matrix I C++ Python O(n * m * r * c) O(1) Medium πŸ”’ Brute Force, Hash Table
3083 Existence of a Substring in a String and Its Reverse C++ Python O(n) O(min(n, 26^2)) Easy Hash Table
3120 Count the Number of Special Characters I C++ Python O(n + 26) O(26) Easy Hash Table
3121 Count the Number of Special Characters II C++ Python O(n + 26) O(26) Medium Hash Table
3137 Minimum Number of Operations to Make Word K-Periodic C++ Python O(n) O(n) Medium Freq Table
3138 Minimum Length of Anagram Concatenation C++ Python O(sqrt(n) * n + 26 * nlogn) O(26) Medium Number Theory, Freq Table
3143 Maximum Points Inside the Square C++ Python O(n + 26) O(26) Medium Hash Table
3146 Permutation Difference between Two Strings C++ Python O(n + 26) O(26) Easy Hash Table
3158 Find the XOR of Numbers Which Appear Twice C++ Python O(n) O(n) Easy Hash Table
3160 Find the Number of Distinct Colors Among the Balls C++ Python O(q) O(q) Medium Freq Table
3167 Better Compression of String C++ Python O(n + 26) O(26) Medium πŸ”’ Freq Table, Counting Sort
3184 Count Pairs That Form a Complete Day I C++ Python O(n + 24) O(24) Easy Freq Table
3185 Count Pairs That Form a Complete Day II C++ Python O(n + 24) O(24) Medium Freq Table
3223 Minimum Length of String After Operations C++ Python O(n + 26) O(26) Medium Freq Table
3237 Alt and Tab Simulation C++ Python O(n) O(n) Medium πŸ”’ Hash Table
3238 Find the Number of Winning Players C++ Python O(p) O(min(n * c, p) Easy Freq Table
3245 Alternating Groups III C++ Python O(nlogn + qlogn) O(n) Hard BST, Sorted List, Freq Table, BIT, Fenwick Tree
3295 Report Spam Message C++ Python O(n + m) O(m) Medium Hash Table
3365 Rearrange K Substrings to Form Target String C++ Python O(n) O(n) Medium Freq Table
3371 Identify the Largest Outlier in an Array C++ Python O(n) O(n) Medium Freq Table
3396 Minimum Number of Operations to Make Elements in Array Distinct C++ Python O(n + r) O(r) Easy Freq Table
3404 Count Special Subsequences C++ Python O(n^2) O(n^2) Medium Freq Table, Number Theory
3438 Find Valid Pair of Adjacent Digits in String C++ Python O(n) O(1) Easy Freq Table
3442 Maximum Difference Between Even and Odd Frequency I C++ Python O(n + 26) O(26) Easy Freq Table
3450 Maximum Students on a Single Bench C++ Python O(n) O(n) Easy πŸ”’ Hash Table, Unordered Set
3471 Find the Largest Almost Missing Integer C++ Python O(n) O(n) Easy Freq Table
3487 Maximum Unique Subarray Sum After Deletion C++ Python O(n) O(n) Easy Hash Table
3488 Closest Equal Element Queries C++ Python O(n) O(n) Medium Hash Table
3527 Find the Most Common Response C++ Python O(n * l) O(n * l) Medium Hash Table, Freq Table
3541 Find Most Frequent Vowel and Consonant C++ Python O(n + 26) O(26) Easy Freq Table
3572 Maximize Y‑Sum by Picking a Triplet of Distinct X‑Values C++ Python O(n) O(n) Medium Hash Table, Quick Select
3581 Count Odd Letters from Number C++ Python O(logn) O(26) Easy πŸ”’ Freq Table
3591 Check if Any Element Has Prime Frequency C++ Python precompute: O(MAX_N)
runtime: O(n)
O(MAX_N) Easy Freq Table, Number Theory, Linear Sieve of Eratosthenes
3636 Threshold Majority Queries C++ Python O(nlogn + qlogq + (n + q) * sqrt(n) * logn) O(q + n) Hard Sort, Coordinate Compression, Sqrt Decomposition, Mo's Algorithm, Freq Table, Sorted List, BST
3662 Filter Characters by Frequency C++ Python O(n + 26) O(26) Easy πŸ”’ Freq Table
3663 Find The Least Frequent Digit C++ Python O(logn + 10) O(10) Easy Freq Table
3668 Restore Finishing Order C++ Python O(n + min(8, n)) O(min(8, n)) Easy Hash Table
3678 Smallest Absent Positive Greater Than Average C++ Python O(n) O(n) Easy Hash Table
3682 Minimum Index Sum of Common Elements C++ Python O(n + m) O(n) Medium πŸ”’ Hash Table
3692 Majority Frequency Characters C++ Python O(n + 26) O(26) Easy Freq Table
3694 Distinct Points Reachable After Substring Removal C++ Python O(n) O(n) Medium Hash Table
3712 Sum of Elements With Frequency Divisible by K C++ Python O(n) O(n) Easy Freq Table
3713 Longest Balanced Substring I C++ Python O(n * (a + n)) O(a) Medium Freq Table
3714 Longest Balanced Substring II C++ Python O(n) O(n) Medium Hash Table, Prefix Sum
3718 Smallest Missing Multiple of K C++ Python O(n) O(n) Easy Hash Table
3728 Stable Subarrays With Equal Boundary and Interior Sum C++ Python O(n) O(n) Medium Freq Table, Prefix Sum
3729 Count Distinct Subarrays Divisible by K in Sorted Array C++ Python O(n) O(min(n, k)) Hard Freq Table, Prefix Sum
3755 Find Maximum Balanced XOR Subarray Length C++ Python O(n) O(n) Medium Hash Table, Prefix Sum
3760 Maximum Substrings With Distinct Start C++ Python O(n + 26) O(26) Medium Hash Table
3761 Minimum Absolute Distance Between Mirror Pairs C++ Python O(nlogr) O(n) Medium Hash Table
3773 Maximum Number of Equal Length Runs C++ Python O(n) O(sqrt(n)) Medium πŸ”’ Freq Table
3779 Minimum Number of Operations to Have Distinct Elements C++ Python O(n) O(n) Medium Hash Table
3784 Minimum Deletion Cost to Make All Characters Equal C++ Python O(n + 26) O(26) Medium Freq Table
3803 Count Residue Prefixes C++ Python O(n + 26) O(26) Easy Hash Table
3804 Number of Centered Subarrays C++ Python O(n^2) O(n) Medium Hash Table
3805 Count Caesar Cipher Pairs C++ Python O(n * m) O(n * m) Medium Freq Table
3810 Minimum Operations to Reach Target Array C++ Python O(n) O(n) Medium Hash Table


Math

# Title Solution Time Space Difficulty Tag Note
3001 Minimum Moves to Capture The Queen C++ Python O(1) O(1) Medium Math
3007 Maximum Number That Sum of the Prices Is Less Than or Equal to K C++ Python O(max(logk, x) * log((logk) / x)) O((logk) / x) Medium Bit Manipulation, Binary Search, Combinatorics
3021 Alice and Bob Playing Flower Game C++ Python O(1) O(1) Medium Combinatorics
3024 Type of Triangle II C++ Python O(1) O(1) Easy Math
3032 Count Numbers With Unique Digits II C++ Python O(logb) O(1) Easy πŸ”’, variant of Count Numbers With Unique Digits Brute Force, Hash Table, Bitmasks, Combinatorics
3047 Find the Largest Area of Square Inside Two Rectangles C++ Python O(n^2) O(1) Meidum Brute Force, Math
3084 Count Substrings Starting and Ending with Given Character C++ Python O(n) O(1) Meidum Combinatorics
3091 Apply Operations to Make Sum of Array Greater Than or Equal to k C++ Python O(logn) O(1) Meidum Codeforces Round #674 C Math
3099 Harshad Number C++ Python O(logx) O(1) Easy Math
3102 Minimize Manhattan Distances C++ Python O(n) O(1) Hard Math
3115 Maximum Prime Difference C++ Python O(r + n) O(r) Medium Array, Number Theory, Linear Sieve of Eratosthenes
3128 Right Triangles C++ Python O(n * m) O(min(n, m)) Medium Array, Combinatorics, Freq Table
3154 Find Number of Ways to Reach the K-th Stair C++ Python O(logk) O(logk) Hard Combinatorics
3155 Maximum Number of Upgradable Servers C++ Python O(n) O(1) Medium πŸ”’ Math
3162 Find the Number of Good Pairs I C++ Python O(rlogr + n + m) O(r) Easy Brute Force, Number Theory, Freq Table
3164 Find the Number of Good Pairs II C++ Python O(rlogr + n + m) O(r) Medium Number Theory, Freq Table
3178 Find the Child Who Has the Ball After K Seconds C++ Python O(1) O(1) Easy Math
3179 Find the N-th Value After K Seconds C++ Python O(n + k) O(n + k) Medium Prefix Sum, Combinatorics
3183 The Number of Ways to Make the Sum C++ Python O(1) O(1) Medium πŸ”’ Math, DP
3190 Find Minimum Operations to Make All Elements Divisible by Three C++ Python O(n) O(1) Easy Math
3200 Maximum Height of a Triangle C++ Python O(logn) O(1) Easy Simulation, Math
3222 Find the Winning Player in Coin Game C++ Python O(1) O(1) Easy Math
3227 Vowels Game in a String C++ Python O(n) O(1) Medium Math
3232 Find if Digit Game Can Be Won C++ Python O(n) O(1) Easy Brute Force, Game Theory
3247 Number of Subsequences with Odd Sum C++ Python O(n) O(1) Medium πŸ”’ Combinatorics, Fast Exponentiation, DP
3250 Find the Count of Monotonic Pairs I C++ Python O(n + r) O(n + r) Hard Combinatorics, Stars and Bars, DP, Prefix Sum
3251 Find the Count of Monotonic Pairs II C++ Python O(n + r) O(n + r) Hard Combinatorics, Stars and Bars, DP, Prefix Sum
3270 Find the Key of the Numbers C++ Python O(d) O(1) Easy Math
3272 Find the Count of Good Integers C++ Python O(n + 10 * 10^((n + 1)/2)) O(n + 10 * (10 * nHr(10, n/2))) Hard Combinatorics, Freq Table
3274 Check if Two Chessboard Squares Have the Same Color C++ Python O(1) O(1) Easy Math, Parity
3284 Sum of Consecutive Subarrays C++ Python O(n) O(1) Medium πŸ”’ Combinatorics
3299 Sum of Consecutive Subsequences C++ Python O(n) O(n) Hard πŸ”’ Combinatorics, Prefix Sum, DP
3312 Sorted GCD Pair Queries C++ Python O(rlogr + qlogr) O(r) Hard Number Theory, Freq Table, Prefix Sum, Binary Search
3317 Find the Number of Possible Ways for an Event C++ Python precompute: O(max_n^2 + max_y * min(max_n, max_x))
runtime: O(min(n, x))
O(max_n^2 + max_y * min(max_n, max_x)) Hard DP, Combinatorics
3326 Minimum Division Operations to Make Array Non Decreasing C++ Python precompute: O(r)
runtime: O(n)
O(r) Medium Greedy, Number Theory, Linear Sieve of Eratosthenes
3339 Find the Number of K-Even Arrays C++ Python O(n) O(n) Medium πŸ”’ DP, Stars and Bars, Combinatorics
3345 Smallest Divisible Digit Product I C++ Python O(logn) O(1) Easy Brute Force
3348 Smallest Divisible Digit Product II C++ Python O(n + logt) O(1) Hard Freq Table, Greedy, Prefix Sum, Number Theory
3360 Stone Removal Game C++ Python O(1) O(1) Easy Math
3395 Subsequences with a Unique Middle Mode I C++ Python O(n) O(n) Hard Freq Table, Prefix Sum, Combinatorics
3405 Count the Number of Arrays with K Matching Adjacent Elements C++ Python O(n + logm) O(n) Hard Combinatorics, Fast Exponentiation
3411 Maximum Subarray With Equal Products C++ Python precompute: O(r * log(logr))
runtime: O(n * log(logr))
O(r * log(logr)) Easy Number Theory, Linear Sieve of Eratosthenes, Hash Table
3416 Subsequences with a Unique Middle Mode II C++ Python O(n) O(n) Hard πŸ”’ Freq Table, Prefix Sum, Combinatorics
3426 Manhattan Distances of All Arrangements of Pieces C++ Python precompute: O(max(m * n))
runtime: O(1)
O(max(m * n)) Hard Combinatorics
3428 Maximum and Minimum Sums of at Most Size K Subsequences C++ Python O(nlogn) O(n) Medium Sort, Combinatorics, Two Pointers, Sliding Window
3447 Assign Elements to Groups with Constraints C++ Python O(m + r * logn) O(r) Medium Hash Table, Number Theory
3448 Count Substrings Divisible By Last Digit C++ Python O(d * n) O(d) Hard DP, Case Works, Math, Freq Table
3461 Check If Digits Are Equal in String After Operations I C++ Python O(nlogn) O(1) Easy Fast Exponentiation, Luca's Theorem, Simulation
3463 Check If Digits Are Equal in String After Operations II C++ Python O(nlogn) O(1) Hard Fast Exponentiation, Lucas's Theorem
3470 Permutations IV C++ Python O(n^2) O(n) Hard Combinatorics
3483 Unique 3-Digit Even Numbers C++ Python O(n) O(1) Easy Freq Table, Combinatorics
3492 Maximum Containers on a Ship C++ Python O(1) O(1) Easy Math
3512 Minimum Operations to Make Array Sum Divisible by K C++ Python O(n) O(1) Easy Math
3513 Number of Unique XOR Triplets I C++ Python O(logn) O(1) Medium Bit Manipulation, Math
3516 Find Closest Person C++ Python O(1) O(1) Easy Math
3519 Count Numbers with Non-Decreasing Digits C++ Python O(n^2) O(n) Hard Math, Stars and Bars, Combinatorics
3556 Sum of Largest Prime Substrings C++ Python O(n^2 * sqrt(r)) O(n^2) Medium Number Theory, Quick Select
3560 Find Minimum Log Transportation Cost C++ Python O(1) O(1) Easy Math
3577 Count the Number of Computer Unlocking Permutations C++ Python O(n) O(1) Medium Combinatorics
3588 Find Maximum Area of a Triangle C++ Python O(n) O(n) Medium Math, Hash Table
3596 Minimum Cost Path with Alternating Directions I C++ Python O(1) O(1) Medium πŸ”’ Math
3602 Hexadecimal and Hexatrigesimal Conversion C++ Python O(logn) O(1) Easy Math
3618 Split Array by Prime Indices C++ Python precompute: O(max_n)
runtime: O(n)
O(max_n) Medium Number Theory, Linear Sieve of Eratosthenes
3621 Number of Integers With Popcount-Depth Equal to K I C++ Python precompute: O((logr)^2)
runtime: O((logn)^2)
O((logr)^2) Hard Combinatorics
3622 Check Divisibility by Digit Sum and Product C++ Python O(logn) O(1) Easy Math
3623 Count Number of Trapezoids I C++ Python O(n) O(n) Medium Freq Table, Combinatorics
3624 Number of Integers With Popcount-Depth Equal to K II C++ Python precompute: O((logr) * log(logr))
runtime: O(nlogr + max_k * n + nlogn + qlogn)
O(logr + max_k * n) Hard BIT, Fenwick Tree
3625 Count Number of Trapezoids II C++ Python O(n^2 * logr) O(n^2) Hard Freq Table, Combinatorics
3648 Minimum Sensors to Cover Grid C++ Python O(1) O(1) Medium Math
3658 GCD of Odd and Even Sums C++ Python O(1) O(1) Easy Math
3659 Partition Array Into K-Distinct Groups C++ Python O(n) O(n) Medium Math, Freq Table
3664 Two-Letter Card Game C++ Python O(n + 26) O(26) Medium Math, Freq Table
3666 Minimum Operations to Equalize Binary String C++ Python O(n) O(1) Hard Math
3671 Sum of Beautiful Subsequences C++ Python precompute: O(rlogr)
runtime: O(nlogr * (log(nlogr) + logn))
O(rlogr) Hard Number Theory, BIT, Fenwick Tree
3677 Count Binary Palindromic Numbers C++ Python O(logn) O(1) Hard Bitmasks, Combinatorics
3697 Compute Decimal Representation C++ Python O(logn) O(1) Easy Math
3726 Remove Zeros in Decimal Representation C++ Python O(logn) O(1) Easy Math, String
3731 Find Missing Elements C++ Python O(n + r) O(n) Easy Hash Table
3745 Maximize Expression of Three Elements C++ Python O(n) O(1) Easy Math
3747 Count Distinct Integers After Removing Zeros C++ Python O(logn) O(1) Medium Combinatorics
3754 Concatenate Non-Zero Digits and Multiply by Sum I C++ Python O(logn) O(1) Easy Math
3765 Complete Prime Number C++ Python O(logn * sqrt(n)) O(1) Medium Prefix Sum, Number Theory
3770 Largest Prime from Consecutive Prime Sum C++ Python precompute: O(r)
runtime: O(logp)
O(sqrt(r)) Medium Precompute, Number Theory, Linear Sieve of Eratosthenes, Binary Search
3783 Mirror Distance of an Integer C++ Python O(logn) O(1) Easy Math
3789 Minimum Cost to Acquire Required Items C++ Python O(1) O(1) Medium Math
3790 Smallest All-Ones Multiple C++ Python O(k) O(1) Medium duplicate of Smallest Integer Divisible by K Math
3798 Largest Even Number C++ Python O(n) O(1) Easy Math
3800 Minimum Cost to Make Two Binary Strings Equal C++ Python O(n) O(1) Medium Math
3817 Good Indices in a Digit String C++ Python O(n) O(1) Medium πŸ”’ Math, Sliding Window
3821 Find Nth Smallest Integer With K One Bits C++ Python ctor: O(r^2)
runtime: O(r)
O(r^2) Hard DP, Combinatorics


Sort

# Title Solution Time Space Difficulty Tag Note
3011 Find if Array Can Be Sorted C++ Python O(n) O(1) Medium Sort
3025 Find the Number of Ways to Place People I C++ Python O(n^2) O(1) Medium Sort, Array
3027 Find the Number of Ways to Place People II C++ Python O(n^2) O(1) Hard Sort, Array
3081 Replace Question Marks in String to Minimize Its Value C++ Python O(n + 26 * log(26)) O(n + 26) Medium Greedy, Counting Sort, Heap, Prefix Sum
3132 Find the Integer Added to Array II C++ Python O(n) O(n) Medium Sort, Paritial Sort, Freq Table
3169 Count Days Without Meetings C++ Python O(nlogn) O(1) Medium Sort
3194 Minimum Average of Smallest and Largest Elements C++ Python O(nlogn) O(1) Easy Sort
3309 Maximum Possible Number by Binary Concatenation C++ Python O(n * logr * logn) O(nlogr) Medium Sort, Brute Force
3394 Check if Grid can be Cut into Sections C++ Python O(nlogn) O(1) Medium Sort, Merge Intervals
3431 Minimum Unlocked Indices to Sort Nums C++ Python O(n) O(1) Medium Sort
3551 Minimum Swaps to Sort by Digit Sum C++ Python O(nlogr + nlogn) O(n) Medium Sort
3631 Sort Threats by Severity and Exploitability C++ Python O(nlogn) O(1) Medium πŸ”’ Sort
3644 Maximum K to Sort a Permutation C++ Python O(n) O(1) Medium Sort, Bitmasks, Constructive Algorithms
3667 Sort Array By Absolute Value C++ Python O(n + r) O(n + r) Easy πŸ”’ Sort
3759 Count Elements With at Least K Greater Values C++ Python O(n) O(1) Medium Sort, Quick Select
3780 Maximum Sum of Three Numbers Divisible by Three C++ Python O(n) O(1) Medium Sort, Math
3799 Word Squares II C++ Python O(n^4) O(1) Medium Sort, Brute Force, Hash Table


Two Pointers

# Title Solution Time Space Difficulty Tag Note
3006 Find Beautiful Indices in the Given Array I C++ Python O(n) O(min(a + b + x + y, n)) Medium KMP Algorithm, Binary Search, Two Pointers
3008 Find Beautiful Indices in the Given Array II C++ Python O(n) O(min(a + b + x + y, n)) Hard KMP Algorithm, Binary Search, Two Pointers
3013 Divide an Array Into Subarrays With Minimum Cost II C++ Python O(nlogd) O(d) Hard Sliding Window, Heap, Freq Table, Ordered Set, BST, Sorted List
3085 Minimum Deletions to Make String K-Special C++ Python O(n + 26) O(n + 26) Medium Freq Table, Counting Sort, Two Pointers
3090 Maximum Length Substring With Two Occurrences C++ Python O(n + 26) O(26) Easy Freq Table, Sliding Window, Two Pointers
3095 Shortest Subarray With OR at Least K I C++ Python O(n * 30) O(30) Easy Brute Force, Freq Table, Two Pointers
3097 Shortest Subarray With OR at Least K II C++ Python O(n * 30) O(30) Medium Freq Table, Two Pointers
3171 Find Subarray With Bitwise OR Closest to K C++ Python O(nlogr) O(logr) Hard variant of Find a Value of a Mysterious Function Closest to Target DP, Freq Table, Two Pointers, Sliding Window
3206 Alternating Groups I C++ Python O(n) O(1) Easy Two Pointers, Sliding Window
3208 Alternating Groups II C++ Python O(n) O(1) Medium Two Pointers, Sliding Window
3234 Count the Number of Substrings With Dominant Ones C++ Python O(n^(3/2)) O(1) Medium Two Pointers, Sliding Window
3254 Find the Power of K-Size Subarrays I C++ Python O(n) O(1) Medium Two Pointers, Sliding Window
3255 Find the Power of K-Size Subarrays II C++ Python O(n) O(1) Medium Two Pointers, Sliding Window
3258 Count Substrings That Satisfy K-Constraint I C++ Python O(n) O(1) Easy Two Pointers, Sliding Window
3261 Count Substrings That Satisfy K-Constraint II C++ Python O(n) O(n) Hard Two Pointers, Sliding Window, Prefix Sum, Hash Table
3264 Final Array State After K Multiplication Operations I C++ Python O(nlogn) O(n) Easy Sort, Two Pointers, Sliding Window, Fast Exponentiation, Heap, Binary Search, Simulation
3266 Final Array State After K Multiplication Operations II C++ Python O(nlogn) O(n) Hard Sort, Two Pointers, Sliding Window, Fast Exponentiation, Heap, Binary Search
3297 Count Substrings That Can Be Rearranged to Contain a String I C++ Python O(n + 26) O(26) Medium Two Pointers, Sliding Window, Freq Table
3298 Count Substrings That Can Be Rearranged to Contain a String II C++ Python O(n + 26) O(26) Hard Two Pointers, Sliding Window, Freq Table
3305 Count of Substrings Containing Every Vowel and K Consonants I C++ Python O(n) O(1) Medium Two Pointers, Sliding Window, Freq Table
3306 Count of Substrings Containing Every Vowel and K Consonants II C++ Python O(n) O(1) Medium Two Pointers, Sliding Window, Freq Table
3318 Find X-Sum of All K-Long Subarrays I C++ Python O(nlogn) O(n) Easy Two Pointers, Sliding Window, Freq Table, Ordered Set, Sorted List
3321 Find X-Sum of All K-Long Subarrays II C++ Python O(nlogn) O(n) Hard Two Pointers, Sliding Window, Freq Table, Ordered Set, Sorted List
3323 Minimize Connected Groups by Inserting Interval C++ Python O(nlogn) O(n) Medium πŸ”’ Sort, Prefix Sum, Two Pointers, Sliding Window
3325 Count Substrings With K-Frequency Characters I C++ Python O(n + 26) O(26) Medium Freq Table, Two Pointers, Sliding Window
3329 Count Substrings With K-Frequency Characters II C++ Python O(n + 26) O(26) Hard πŸ”’ Freq Table, Two Pointers, Sliding Window
3346 Maximum Frequency of an Element After Performing Operations I C++ Python O(nlogn) O(n) Medium Sort, Freq Table, Two Pointers, Sliding Window, Difference Array, Line Sweep
3347 Maximum Frequency of an Element After Performing Operations II C++ Python O(nlogn) O(n) Hard Sort, Freq Table, Two Pointers, Sliding Window, Difference Array, Line Sweep
3364 Minimum Positive Sum Subarray C++ Python O(nlogn) O(n) Easy Prefix Sum, Two Pointers, Sliding Window, Sorted List, BST, Binary Search
3413 Maximum Coins From K Consecutive Bags C++ Python O(nlogn) O(1) Medium Sort, Two Pointers, Sliding Window
3420 Count Non-Decreasing Subarrays After K Operations C++ Python O(n) O(n) Hard Mono Deque, Two Pointers, Sliding Window
3422 Minimum Operations to Make Subarray Elements Equal C++ Python O(nlogk) O(k) Medium πŸ”’ Math, Two Pointers, Sliding Window, Sorted List, BST
3425 Longest Special Path C++ Python O(n + e) O(n + e) Hard DFS, Two Pointers, Sliding Window, Prefix Sum
3430 Maximum and Minimum Sums of at Most Size K Subarrays C++ Python O(n) O(k) Hard Two Pointers, Sliding Window, Mono Deque
3439 Reschedule Meetings for Maximum Free Time I C++ Python O(n) O(1) Medium Two Pointers, Sliding Window
3445 Maximum Difference Between Even and Odd Frequency II C++ Python O(d^2 * n) O(n) Hard Prefix Sum, Two Pointers, Sliding Window
3460 Longest Common Prefix After at Most One Removal C++ Python O(n) O(1) Medium πŸ”’ Two Pointers
3485 Longest Common Prefix of K Strings After Removal C++ Python O(l * nlogn) O(n) Hard Sort, Sliding Window, Prefix Sum, Trie
3486 Longest Special Path II C++ Python O(n + e) O(n + e) Hard DFS, Two Pointers, Sliding Window, Prefix Sum
3555 Smallest Subarray to Sort in Every Sliding Window C++ Python O(n) O(n) Medium πŸ”’ Mono Stack, Two Pointers
3567 Minimum Absolute Difference in Sliding Submatrix C++ Python O(m * n * k^2) O(k^2) Medium Brute Force, Sort, Two Pointers, Sliding Window, BST, Sorted List
3584 Maximum Product of First and Last Elements of a Subsequence C++ Python O(n) O(1) Medium Two Pointers, Sliding Window
3589 Count Prime-Gap Balanced Subarrays C++ Python precompute: O(r)
runtime: O(n)
O(r) Medium Number Theory, Linear Sieve of Eratosthenes, Mono Deque, Two Pointers, Sliding Window
3634 Minimum Removals to Balance Array C++ Python O(nlogn) O(1) Medium Sort, Two Pointers, Sliding Window
3640 Trionic Array II C++ Python O(n) O(1) Easy Two Pointers, Sliding Window, Greedy
3641 Longest Semi-Repeating Subarray C++ Python O(n) O(1) Medium πŸ”’ Freq Table, Two Pointers, Sliding Window
3649 Number of Perfect Pairs C++ Python O(nlogn) O(1) Medium Sort, Two Pointers, Sliding Window, Math
3652 Best Time to Buy and Sell Stock using Strategy C++ Python O(n) O(1) Medium Two Pointers, Sliding Window
3672 Sum of Weighted Modes in Subarrays C++ Python O(nlogk) O(k) Medium πŸ”’ Sorted List, BST, Two Pointers, Sliding Window
3679 Minimum Discards to Balance Inventory C++ Python O(n) O(w) Medium Freq Table, Two Pointers, Sliding Window
3698 Split Array With Minimum Difference C++ Python O(n) O(1) Medium Two Pointers
3740 Minimum Distance Between Three Equal Elements I C++ Python O(n) O(n) Easy Hash Table, Two Pointers, Sliding Window
3741 Minimum Distance Between Three Equal Elements II C++ Python O(n) O(n) Medium Hash Table, Two Pointers, Sliding Window
3768 Minimum Inversion Count in Subarrays of Fixed Length C++ Python O(nlogn) O(n) Hard Sort, Coordinate Compression, BIT, Fenwick Tree, Two Pointers, Sliding Window
3795 Minimum Subarray Length With Distinct Sum At Least K C++ Python O(n) O(n) Medium Freq Table, Two Pointers, Sliding Window
3802 Number of Ways to Paint Sheets C++ Python O(mlogm) O(m) Hard πŸ”’ Prefix Sum, Two Pointers
3835 Count Subarrays With Cost Less Than or Equal to K C++ Python O(n) O(n) Medium Mono Deque, Two Pointers, Sliding Window


Recursion

# Title Solution Time Space Difficulty Tag Note


Binary Search

# Title Solution Time Space Difficulty Tag Note
3048 Earliest Second to Mark Indices I C++ Python O(mlogm) O(n) Medium Binary Search, Greedy
3049 Earliest Second to Mark Indices II C++ Python O((m + nlogn) *logm) O(n) Hard Binary Search, Greedy, Heap
3104 Find Longest Self-Contained Substring C++ Python O(n + 26^3 * logn) O(n) Hard πŸ”’ Brute Force, Freq Table, Two Pointers, Hash Table, Binary Search
3116 Kth Smallest Amount With Single Denomination Combination C++ Python O(n * 2^n * logk) O(2^n) Hard Binary Search, Principle of Inclusion and Exclusion, Number Theory
3134 Find the Median of the Uniqueness Array C++ Python O(nlogn) O(n) Hard Binary Search, Two Pointers, Sliding Window
3135 Equalize Strings by Adding or Removing Characters at Ends C++ Python O((n + m) * log(min(n, m))) O(min(n, m)) Medium πŸ”’ Binary Search, Rabin-Karp Algorithm, Rolling Hash, DP
3145 Find Products of Elements of Big Array C++ Python O(q * (logr)^2) O(1) Hard Binary Search, Combinatorics, Bitmasks, Fast Exponentiation
3231 Minimum Number of Increasing Subsequence to Be Removed C++ Python O(nlogn) O(n) Hard πŸ”’, variant of Longest Increasing Subsequence Binary Search
3233 Find the Count of Numbers Which Are Not Special C++ Python precompute: O(sqrt(r))
runtime: O(logr)
O(sqrt(r)) Medium Number Theory, Linear Sieve of Eratosthenes, Binary Search
3281 Maximize Score of Numbers in Ranges C++ Python O(nlogr) O(1) Medium Binary Search, Greedy
3288 Length of the Longest Increasing Path C++ Python O(nlogn) O(n) Hard Sort, Binary Search, Longest Increasing Subsequence
3296 Minimum Number of Seconds to Make Mountain Height Zero C++ Python O(nlogr) O(1) Medium Binary Search, Quadratic Equation, Heap
3356 Zero Array Transformation II C++ Python O((n + q) * logn) O(n) Medium Binary Search, Line Sweep
3357 Minimize the Maximum Adjacent Element Difference C++ Python O(nlogr) O(1) Hard Binary Search
3398 Smallest Substring With Identical Characters I C++ Python O(nlogn) O(1) Hard Binary Search, Greedy
3399 Smallest Substring With Identical Characters II C++ Python O(nlogn) O(1) Hard Binary Search, Greedy
3449 Maximize the Minimum Game Score C++ Python O(n * log(m * r)) O(1) Hard Binary Search, Greedy
3464 Maximize the Distance Between Points on a Square C++ Python O(nlogn + nlogs) O(n) Hard Sort, Binary Search, Greedy, Two Pointers, Sliding Window
3477 Fruits Into Baskets II C++ Python O(nlogn) O(n) Easy Segment Tree, Binary Search, Brute Force
3479 Fruits Into Baskets III C++ Python O(nlogn) O(n) Medium Segment Tree, Binary Search
3520 Minimum Threshold for Inversion Pairs Count C++ Python O(nlogn * logr) O(n) Medium πŸ”’ Binary Search, Sorted List, Ordered Set
3605 Minimum Stability Factor of Array C++ Python O(nlogn * logr) O(nlogn) Hard Number Theory, Binary Search, RMQ, Sparse Table, Greedy
3722 Lexicographically Smallest String After Reverse C++ Python O(nlogn) O(n) Medium String, Brute Force, Binary Search, Rabin-Karp Algorithm, Rolling Hash
3733 Minimum Time to Complete All Deliveries C++ Python O(logr + logd) O(1) Medium Binary Search
3735 Lexicographically Smallest String After Reverse II C++ Python O(nlogn) O(n) Hard πŸ”’ Binary Search, Rabin-Karp Algorithm, Rolling Hash
3771 Total Score of Dungeon Runs C++ Python O(nlogn) O(n) Medium Prefix Sum, Binary Search
3807 Minimum Cost to Repair Edges to Traverse a Graph C++ Python O((n + m) * logr) O(n + m) Medium πŸ”’ Binary Search, BFS
3824 Minimum K to Reduce Array Within Limit C++ Python O(nlogn + nlogr) O(1) Medium Binary Search
3825 Longest Strictly Increasing Subsequence With Non-Zero Bitwise AND C++ Python O(logr * nlogn) O(n) Medium Bitmasks, LIS, Longest Increasing Subsequence, Binary Search
3826 Minimum Partition Score C++ Python O(nlogn + nlogr) O(n) Hard Prefix Sum, DP, Convex Hull Trick, WQS Binary Search, Alien Trick


Binary Search Tree

# Title Solution Time Space Difficulty Tag Note
3072 Distribute Elements Into Two Arrays II C++ Python O(nlogn) O(n) Hard Sorted List, Ordered Set
3073 Maximum Increasing Triplet Value C++ Python O(nlogn) O(n) Medium πŸ”’ Sorted List, BST, Prefix Sum
3161 Block Placement Queries C++ Python O(qlogq) O(q) Hard Sorted List, BST, BIT, Fenwick Tree, Segment Tree
3165 Maximum Sum of Subsequence With Non-adjacent Elements C++ Python O(n + qlogn) O(n) Hard Segment Tree
3526 Range XOR Queries with Subarray Reversals C++ Python O(n + qlogn) O(n) Hard πŸ”’ Treap


Breadth-First Search

# Title Solution Time Space Difficulty Tag Note
3157 Find the Level of Tree with Minimum Sum C++ Python O(n) O(w) Medium πŸ”’ BFS
3286 Find a Safe Walk Through a Grid C++ Python O(m * n) O(m * n) Medium variant of Minimum Obstacle Removal to Reach Corner 0-1 BFS, Deque
3373 Maximize the Number of Target Nodes After Connecting Trees II C++ Python O(n + m) O(n + m) Hard BFS
3528 Unit Conversion I C++ Python O(n) O(n) Medium BFS
3535 Unit Conversion II C++ Python O(n + qlogm) O(n) Medium πŸ”’ BFS, Fast Exponentiation
3552 Grid Teleportation Traversal C++ Python O(m * n) O(m * n) Medium 0-1 BFS, Deque
3568 Minimum Moves to Clean the Classroom C++ Python O(m * n * 2^l) O(m * n * 2^l) Medium BFS, Bitmasks
3619 Count Islands With Total Value Divisible by K C++ Python O(m * n) O(m + n) Medium BFS, Flood Fill
3629 Minimum Jumps to Reach End via Prime Teleportation C++ Python precompute: O(r)
runtime: O(nlogr)
O(r + nlogr) Medium Number Theory, Linear Sieve of Eratosthenes, BFS
3690 Split and Merge Array Transformation C++ Python O(n^4 * n!) O(n * n!) Medium BFS
3695 Maximize Alternating Sum Using Swaps C++ Python O(n + s) O(n + s) Hard BFS, Flood Fill, Quick Select
3786 Total Sum of Interaction Cost in Tree Groups C++ Python O(nlogn) O(n) Hard BFS, DFS, Small-to-Large Merging
3787 Find Diameter Endpoints of a Tree C++ Python O(n) O(n) Medium πŸ”’ BFS, Tree Diameter
3820 Pythagorean Distance Nodes in a Tree C++ Python O(n) O(n) Medium BFS
3831 Median of a Binary Search Tree Level C++ Python O(n) O(n) Medium πŸ”’ BFS


Depth-First Search

# Title Solution Time Space Difficulty Tag Note
3004 Maximum Subtree of the Same Color C++ Python O(n) O(h) Medium πŸ”’ DFS
3067 Count Pairs of Connectable Servers in a Weighted Tree Network C++ Python O(n^2) O(n) Medium DFS, BFS
3203 Find Minimum Diameter After Merging Two Trees C++ Python O(n + m) O(n + m) Hard variant of Tree Diameter DFS, BFS, Tree DP, Tree Diameter
3249 Count the Number of Good Nodes C++ Python O(n) O(h) Medium DFS
3319 K-th Largest Perfect Subtree Size in Binary Tree C++ Python O(n) O(n) Medium DFS, Quick Select
3327 Check if DFS Strings Are Palindromes C++ Python O(n) O(n) Hard DFS, Manacher's Algorithm
3331 Find Subtree Sizes After Changes C++ Python O(n) O(n) Medium DFS, Hash Table
3367 Maximize Sum of Weights after Edge Removals C++ Python O(n) O(n) Hard DFS, Quick Select
3590 Kth Smallest Path XOR Sum C++ Python O(n * (logn)^2 + qlogn) O(n + q) Hard DFS, Small-to-Large Merging, Ordered Set, Sorted List
3593 Minimum Increments to Equalize Leaf Paths C++ Python O(n) O(n) Medium DFS
3607 Power Grid Maintenance C++ Python O(c + n + q) O(c + n) Medium DFS, Flood Fill, Sort


Backtracking

# Title Solution Time Space Difficulty Tag Note
3211 Generate Binary Strings Without Adjacent Zeros C++ Python O(n * 2^n) O(n) Medium Backtracking, BFS
3437 Permutations III C++ Python O(n * n!) O(n) Medium πŸ”’ Backtracking, Bitmasks
3565 Sequential Grid Path Cover C++ Python O(m * n * 3^(m * n)) O(m * n) Medium πŸ”’ Backtracking
3669 Balanced K-Factor Decomposition C++ Python precompute: O(rlogr)
runtime: O(k * (logn)^(k - 1))
O(rlogr) Medium Backtracking, Number Theory


Dynamic Programming

# Title Solution Time Space Difficulty Tag Note
3018 Maximum Number of Removal Queries That Can Be Processed I C++ Python O(n^2) O(n^2) Hard πŸ”’ DP
3020 Find the Maximum Number of Elements in Subset C++ Python O(n) O(n) Medium Freq Table, DP
3040 Maximum Number of Operations With the Same Score II C++ Python O(n^2) O(n^2) Medium Memoization
3041 Maximize Consecutive Elements in an Array After Modification C++ Python O(nlogn) O(1) Hard Sort, DP
3077 Maximum Strength of K Disjoint Subarrays C++ Python O(k * n) O(n) Hard DP, Greedy, Kadane's Algorithm
3082 Find the Sum of the Power of All Subsequences C++ Python O(n * k) O(k) Hard DP, Combinatorics
3098 Find the Sum of Subsequence Powers C++ Python O(n^3 * k) O(n^2) Hard DP, Prefix Sum, Two Pointers
3101 Count Alternating Subarrays C++ Python O(n) O(1) Medium DP
3117 Minimum Sum of Values by Dividing Array C++ Python O(n * m * logr) O(n + logr) Hard Memoization, DP, RMQ, Sparse Table, Mono Deque, Two Pointers
3122 Minimum Number of Operations to Satisfy Conditions C++ Python O(n * (m + 10)) O(10) Medium DP
3129 Find All Possible Stable Binary Arrays I C++ Python O(n * m) O(n * m) Medium DP
3130 Find All Possible Stable Binary Arrays II C++ Python O(n * m) O(n * m) Hard DP
3141 Maximum Hamming Distances C++ Python O(m * 2^m) O(2^m) Hard πŸ”’ Bitmasks, BFS, Knapsack DP
3144 Minimum Substring Partition of Equal Character Frequency C++ Python O(n * (n + 26)) O(n + 26) Medium DP, Freq Table
3148 Maximum Difference Score in a Grid C++ Python O(m * n) O(1) Medium DP
3149 Find the Minimum Cost Array Permutation C++ Python O((n-1)^2 * 2^(n-1)) O((n-1) * 2^(n-1)) Hard DP, Backtracing
3176 Find the Maximum Length of a Good Subsequence I C++ Python O(n * k) O(n * k) Medium DP
3177 Find the Maximum Length of a Good Subsequence II C++ Python O(n * k) O(n * k) Hard DP
3180 Maximum Total Reward Using Operations I C++ Python O(n * k) O(n * k) Medium Sort, DP, Bitset
3181 Maximum Total Reward Using Operations II C++ Python O(n * k) O(n * k) Hard Sort, DP, Bitset
3186 Maximum Total Damage With Spell Casting C++ Python O(nlogn) O(n) Medium Sort, DP, Two Pointers, Sliding window, Deque
3193 Count the Number of Inversions C++ Python O(n * k) O(n + k) Hard variant of K Inverse Pairs Array Knapsack DP, Combinatorics, Sliding Window, Two Pointers
3196 Maximize Total Cost of Alternating Subarrays C++ Python O(n) O(1) Medium DP
3197 Find the Minimum Area to Cover All Ones II C++ Python O(max(n, m)^2) O(max(n, m)^2) Hard Array, Brute Force, Prefix Sum, Binary Search, RMQ, Sparse Table, DP
3201 Find the Maximum Length of Valid Subsequence I C++ Python O(n) O(1) Medium Brute Force, DP
3202 Find the Maximum Length of Valid Subsequence II C++ Python O(n * k) O(k) Medium DP
3209 Number of Subarrays With AND Value of K C++ Python O(nlogr) O(logr) Hard variant of Find Subarray With Bitwise OR Closest to K DP
3212 Count Submatrices With Equal Frequency of X and Y C++ Python O(n * m) O(n * m) Medium DP
3213 Construct String with Minimum Cost C++ Python O(n^2 + w * l) O(t) Hard DP, Trie
3225 Maximum Score From Grid Operations C++ Python O(n^3) O(n) Hard Prefix Sum, DP
3241 Time Taken to Mark All Nodes C++ Python O(n) O(n) Hard Tree DP, BFS, DFS
3253 Construct String with Minimum Cost (Easy) C++ Python O(n * w * l) O(l) Medium πŸ”’ DP, Trie
3259 Maximum Energy Boost From Two Drinks C++ Python O(n) O(1) Medium DP
3269 Constructing Two Increasing Arrays C++ Python O(m * n) O(min(m, n)) Hard πŸ”’ DP
3277 Maximum XOR Score Subarray Queries C++ Python O(n^2 + q) O(n^2) Hard DP
3283 Maximum Number of Moves to Kill All Pawns C++ Python O(p^2 * 2^p) O(p * 2^p) Hard BFS, Bitmasks, DP
3287 Find the Maximum Sequence Value of Array C++ Python O(n * r + r^2) O(r) Hard Bitmasks, Prefix Sum, DP
3290 Maximum Multiplication Score C++ Python O(n) O(1) Medium DP
3291 Minimum Number of Valid Strings to Form Target I C++ Python O(n + w * l) O(n + t) Medium KMP, Rabin-Karp Algorithm, Rolling Hash, Hash Table, Two Pointers, Sliding Window, DP, Aho-Corasick Automata, Trie
3292 Minimum Number of Valid Strings to Form Target II C++ Python O(n + w * l) O(n + t) Hard KMP, Rabin-Karp Algorithm, Rolling Hash, Hash Table, Two Pointers, Sliding Window, DP, Aho-Corasick Automata, Trie
3313 Find the Last Marked Nodes in Tree C++ Python O(n) O(n) Hard πŸ”’, variant of Time Taken to Mark All Nodes BFS, DFS, Tree DP, Tree Diameter
3316 Find Maximum Removals From Source String C++ Python O(n * m) O(n + m) Medium DP
3320 Count The Number of Winning Sequences C++ Python O(n^2) O(n) Hard DP
3332 Maximum Points Tourist Can Earn C++ Python O(k * n^2) O(n) Hard DP
3333 Find the Original Typed String II C++ Python O(n + k^2) O(n + k) Hard DP
3335 Total Characters in String After Transformations I C++ Python precompute: O(t + 26)
runtime: O(n)
O(t + 26) Medium DP, Matrix Exponentiation, Precompute
3336 Find the Number of Subsequences With Equal GCD C++ Python precompute: O(max_r^2 * log(max_r))
runtime: O(n + r^2)
O(max_r^2) Hard DP, Number Theory, Mobius Function, Principle of Inclusion-Exclusion, Basel Problem
3337 Total Characters in String After Transformations II C++ Python O(n + 26^3 * logt) O(26^2) Hard DP, Matrix Exponentiation
3343 Count Number of Balanced Permutations C++ Python O(n^2) O(n^2) Hard DP, Combinatorics
3351 Sum of Good Subsequences C++ Python O(n) O(n) Hard Freq Table, DP
3352 Count K-Reducible Numbers Less Than N C++ Python O(n^2) O(n) Hard DP, Combinatorics
3359 Find Sorted Submatrices With Maximum Element at Most K C++ Python O(m * n) O(m) Hard πŸ”’, variant of Count Submatrices With All Ones Mono Stack, DP
3363 Find the Maximum Number of Fruits Collected C++ Python O(n^2) O(1) Hard DP
3366 Minimum Array Sum C++ Python O(nlogn) O(n) Medium DP, Greedy, Case Works
3372 Maximize the Number of Target Nodes After Connecting Trees I C++ Python O(nlogn + mlogm) O(n + m) Medium Brute Force, BFS, DFS, Tree DP, Centroid Decomposition, Prefix Sum
3381 Maximum Subarray Sum With Length Divisible by K C++ Python O(n) O(k) Medium Prefix Sum, DP
3388 Count Beautiful Splits in an Array C++ Python O(n^2) O(n) Medium DP, Z-Function
3389 Minimum Operations to Make Character Frequencies Equal C++ Python O(26 * n) O(26) Hard Freq Table, DP
3393 Count Paths With the Given XOR Value C++ Python O(m * n * r) O(n * r) Medium DP
3409 Longest Subsequence With Decreasing Adjacent Difference C++ Python O(r^2 + n * r) O(r^2) Medium DP
3414 Maximum Score of Non-overlapping Intervals C++ Python O(nlogn + n * k^2) O(n * k^2) Hard DP, Binary Search
3418 Maximum Amount of Money Robot Can Earn C++ Python O(m * n) O(min(m, n)) Medium DP
3429 Paint House IV C++ Python O(n * l^4) O(l^2) Medium DP
3434 Maximum Frequency After Subarray Operation C++ Python O(n) O(n) Medium Freq Table, DP
3441 Minimum Cost Good Caption C++ Python O(26 * n) O(26 * n) Hard DP, Backtracing
3444 Minimum Increments for Target Multiples in an Array C++ Python O(logr * m * 2^m + n * 3^m) O(2^m) Hard Bitmasks, Number Theory, DP, Submask Enumeration
3459 Length of Longest V-Shaped Diagonal Segment C++ Python O(n * m) O(n * m) Hard Memoization, DP
3466 Maximum Coin Collection C++ Python O(n) O(1) Medium πŸ”’ DP
3469 Find Minimum Cost to Remove Array Elements C++ Python O(n^2) O(n) Medium DP, Greedy
3472 Longest Palindromic Subsequence After at Most K Operations C++ Python O(n^2 * k) O(n^2 * k) Medium DP
3473 Sum of K Subarrays With Length at Least M C++ Python O(k * n) O(n) Medium Prefix Sum, DP
3489 Zero Array Transformation IV C++ Python O(n^2 * r * logq) O(r) Medium Binary Search, DP
3490 Count Beautiful Numbers C++ Python O(logr * 2 * 10 * s) O(logr * 2 * 10 * s) Hard DP
3500 Minimum Cost to Divide Array Into Subarrays C++ Python O(nlogn) O(n) Hard Prefix Sum, DP, Convex Hull Trick
3503 Longest Palindrome After Substring Concatenation I C++ Python O(n * m) O(n + m) Medium Manacher's Algorithm, DP
3504 Longest Palindrome After Substring Concatenation II C++ Python O(n * m) O(n + m) Hard Manacher's Algorithm, DP
3505 Minimum Operations to Make Elements Within K Subarrays Equal C++ Python O(nlogx + k * n) O(n) Hard Two Heaps, Two BSTs, Two Sorted Lists, DP
3509 Maximum Product of Subsequences With an Alternating Sum Equal to K C++ Python O(n * k * l) O(n * k * l) Hard DP
3524 Find X Value of Array I C++ Python O(n * k) O(k) Medium DP
3525 Find X Value of Array II C++ Python O(n * k + q * k * logn) O(n * k) Hard DP, Segment Tree
3530 Maximum Profit from Valid Topological Order in DAG C++ Python O(n * 2^n) O(2^n) Hard DP, Bitmasks
3533 Concatenated Divisibility C++ Python O(nlogr + k * n * 2^n) O(logr + k * 2^n) Hard DP, Bitmasks, Backtracing
3538 Merge Operations for Minimum Travel Time C++ Python O((n-k) * k^3) O(k^2) Hard Prefix Sum, DP
3539 Find Sum of Array Product of Magical Sequences C++ Python O(n * k * m^2) O(k * m^2) Hard DP, Combinatorics
3543 Maximum Weighted K-Edge Path C++ Python O(k * e * t) O(n * t) Medium DP
3544 Subtree Inversion Sum C++ Python O(n) O(n) Hard DFS, Tree DP
3562 Maximum Profit from Trading Stocks with Discounts C++ Python O(n * b) O(n + b) Hard DFS, Tree DP
3563 Lexicographically Smallest String After Adjacent Removals C++ Python O(n^3) O(n^2) Hard DP
3573 Best Time to Buy and Sell Stock V C++ Python O(n * k) O(k) Medium DP
3574 Maximize Subarray GCD Score C++ Python O(nlogn * logr) O(n + logr) Hard Brute Force, Number Theory, Suffix-GCD States, DP, Binary Search
3575 Maximum Good Subtree Score C++ Python O(n * (2^10)^2) O(2^10) Hard Bitmasks, DFS, Tree DP
3578 Count Partitions With Max-Min Difference at Most K C++ Python O(n) O(n) Medium Mono Deque, Two Pointers, Sliding Window, DP, Prefix Sum
3579 Minimum Steps to Convert String with Operations C++ Python O(n^2) O(26^2) Hard DP
3583 Count Special Triplets C++ Python O(n) O(n) Medium DP, Freq Table
3592 Inverse Coin Change C++ Python O(n^2) O(1) Medium DP
3595 Once Twice C++ Python O(n) O(1) Medium πŸ”’ DP, Bitmasks
3599 Partition Array to Minimize XOR C++ Python O(n^2 * k) O(n) Medium DP, Prefix Sum
3603 Minimum Cost Path with Alternating Directions II C++ Python O(m * n) O(1) Medium DP
3610 Minimum Number of Primes to Sum to Target C++ Python O(nlog(log(min(m, n))) + m * n) O(n) Medium πŸ”’ Number Theory, Knapsack DP
3615 Longest Palindromic Path in Graph C++ Python O(n^4 * 2^n) O(n + e) Hard Bitmasks, DP, Freq Table
3628 Maximum Number of Subsequences After One Inserting C++ Python O(n) O(1) Medium Prefix Sum, DP
3647 Maximum Weight in Two Bags C++ Python O(n * w1 * w2) O(w1 * w2) Medium πŸ”’ DP, Bitset
3651 Minimum Cost Path with Teleportations C++ Python O(k * (m * n + r)) O(m * n + r) Hard DP, Prefix Sum
3654 Minimum Sum After Divisible Sum Deletions C++ Python O(n + k) O(k) Medium DP, Prefix Sum
3661 Maximum Walls Destroyed by Robots C++ Python O(nlogn + mlogm) O(n) Hard Sort, DP, Two Pointers
3665 Twisted Mirror Path Count C++ Python O(m * n) O(min(m, n)) Medium DP
3670 Maximum Product of Two Integers With No Common Bits C++ Python O(n + rlogr) O(r) Medium DP, Bitmasks
3685 Subsequence Sum After Capping Elements C++ Python O(nlogn + n * k) O(k) Medium Sort, DP, Bitmasks
3686 Number of Stable Subsequences C++ Python O(n) O(1) Hard DP
3693 Climbing Stairs II C++ Python O(n) O(1) Medium DP
3699 Number of ZigZag Arrays I C++ Python O(n * (r - l)) O(r - l) Hard DP
3704 Count No-Zero Pairs That Sum to N C++ Python O(10 * 2^4 * logn) O(2^3) Hard DP
3717 Minimum Operations to Make the Array Beautiful C++ Python O(n * rlogr) O(r) Medium πŸ”’ DP
3725 Count Ways to Choose Coprime Integers from Rows C++ Python O(n * rlogr) O(r) Hard DP, Number Theory, Linear Sieve of Eratosthenes, Mobius Function, Principle of Inclusion-Exclusion
3742 Maximum Path Score in a Grid C++ Python O(m * n * k) O(m * n * k) Medium DP
3743 Maximize Cyclic Partition Score C++ Python O(n * k) O(k) Hard variant of Best Time to Buy and Sell Stock V DP
3753 Total Waviness of Numbers in Range II C++ Python O(logn * 11 * 11 * 2 * 2 * 10) O(11 * 11 * 2 * 2) Hard DP, Memoization
3757 Number of Effective Subsequences C++ Python O((n + r) * logr) O(n + r) Hard SOS DP, Principle of Inclusion and Exclusion
3772 Maximum Subgraph Score in a Tree C++ Python O(n) O(n) Hard BFS, Tree DP
3791 Number of Balanced Integers in a Range C++ Python O((logn)^2) O(logn) Hard DP, Memoization
3801 Minimum Cost to Merge Sorted Lists C++ Python O(l * nlogn + 2^n * log(n * l) * n * logl + 3^n) O(n * l + 2^n) Hard DP, Sort, Heap, Binary Search, Submask Enumeration
3811 Number of Alternating XOR Partitions C++ Python O(n) O(1) Medium DP, Freq Table
3830 Longest Alternating Subarray After Removing At Most One Element C++ Python O(n) O(1) Hard DP
3836 Maximum Score Using Exactly K Pairs C++ Python O(n * m * k) O(min(n, m) * k) Hard DP


Greedy

# Title Solution Time Space Difficulty Tag Note
3002 Maximum Size of a Set After Removals C++ Python O(n) O(n) Medium Math, Hash Table, Greedy
3003 Maximize the Number of Partitions After Operations C++ Python O(n) O(n) Hard Prefix Sum, Greedy
3012 Minimize Length of Array Using Operations C++ Python O(n) O(1) Medium Greedy
3014 Minimum Number of Pushes to Type Word I C++ Python O(4) O(1) Easy Freq Table, Greedy
3016 Minimum Number of Pushes to Type Word II C++ Python O(n) O(26) Medium Freq Table, Greedy
3022 Minimize OR of Remaining Elements Using Operations C++ Python O(nlogr) O(1) Hard Bitmasks, Greedy
3035 Maximum Palindromes After Operations C++ Python O(n * l + nlogn) O(n) Medium Freq Table, Greedy, Sort
3068 Find the Maximum Sum of Node Values C++ Python O(n) O(1) Hard Greedy
3074 Apple Redistribution into Boxes C++ Python O(nlogn) O(1) Easy Sort, Greedy
3075 Maximize Happiness of Selected Children C++ Python O(nlogn) O(1) Medium Sort, Greedy
3086 Minimum Moves to Pick K Ones C++ Python O(n) O(n) Hard Prefix Sum, Greedy
3088 Make String Anti-palindrome C++ Python O(n + 26) O(26) Hard πŸ”’ Freq Table, Counting Sort, Greedy, Two Pointers
3106 Lexicographically Smallest String After Operations With Constraint C++ Python O(n) O(1) Medium Greedy
3107 Minimum Operations to Make Median of Array Equal to K C++ Python O(n) O(1) Medium Sort, Quick Select, Greedy
3111 Minimum Rectangles to Cover Points C++ Python O(nlogn) O(n) Medium Sort, Greedy
3114 Latest Time You Can Obtain After Replacing Characters C++ Python O(1) O(1) Easy String, Greedy
3119 Maximum Number of Potholes That Can Be Fixed C++ Python O(n) O(n) Medium πŸ”’ Sort, Counting Sort, Greedy
3170 Lexicographically Minimum String After Removing Stars C++ Python O(n + 26) O(n + 26) Medium Greedy, Hash Table, Stack
3189 Minimum Moves to Get a Peaceful Board C++ Python O(n) O(n) Medium πŸ”’, variant of Distribute Coins in Binary Tree Counting Sort, Prefix Sum, Greedy
3191 Minimum Operations to Make Binary Array Elements Equal to One I C++ Python O(n) O(1) Medium Greedy
3192 Minimum Operations to Make Binary Array Elements Equal to One II C++ Python O(n) O(1) Medium Greedy
3205 Maximum Array Hopping Score I C++ Python O(n) O(1) Medium πŸ”’ DP, Prefix Sum, Greedy
3207 Maximum Points After Enemy Battles C++ Python O(n) O(1) Medium Greedy
3216 Lexicographically Smallest String After a Swap C++ Python O(n) O(1) Easy Greedy
3218 Minimum Cost for Cutting Cake I C++ Python O(mlogm + nlogn) O(1) Medium Memoization, Greedy
3219 Minimum Cost for Cutting Cake II C++ Python O(mlogm + nlogn) O(1) Hard Greedy
3221 Maximum Array Hopping Score II C++ Python O(n) O(1) Medium πŸ”’ Prefix Sum, Greedy
3228 Maximum Number of Operations to Move Ones to the End C++ Python O(n) O(1) Medium Greedy
3229 Minimum Operations to Make Array Equal to Target C++ Python O(n) O(1) Hard variant of Minimum Number of Increments on Subarrays to Form a Target Array Greedy
3239 Minimum Number of Flips to Make Binary Grid Palindromic I C++ Python O(m * n) O(1) Medium Array, Greedy
3240 Minimum Number of Flips to Make Binary Grid Palindromic II C++ Python O(m * n) O(1) Medium Array, Greedy
3273 Minimum Amount of Damage Dealt to Bob C++ Python O(nlogn) O(n) Hard Sort, Greedy
3282 Reach End of Array With Max Score C++ Python O(n) O(1) Medium Greedy
3301 Maximize the Total Height of Unique Towers C++ Python O(nlogn) O(1) Medium Sort, Greedy
3302 Find the Lexicographically Smallest Valid Sequence C++ Python O(n + m) O(m) Medium Hash Table, Greedy
3362 Zero Array Transformation III C++ Python O(n + qlogq) O(q) Medium Sort, Heap, Greedy
3397 Maximum Number of Distinct Elements After Operations C++ Python O(nlogn) O(1) Medium Sort, Greedy
3402 Minimum Operations to Make Columns Strictly Increasing C++ Python O(m * n) O(1) Easy Greedy
3403 Find the Lexicographically Largest String From the Box I C++ Python O(n) O(1) Medium Greedy
3406 Find the Lexicographically Largest String From the Box II C++ Python O(n) O(1) Hard πŸ”’ Greedy
3410 Maximize Subarray Sum After Removing All Occurrences of One Element C++ Python O(n) O(n) Hard Prefix Sum, Greedy, Kadane's Algorithm, Segment Tree
3424 Minimum Cost to Make Arrays Identical C++ Python O(nlogn) O(1) Medium Sort, Greedy
3443 Maximum Manhattan Distance After K Changes C++ Python O(n) O(1) Medium Greedy
3457 Eat Pizzas! C++ Python O(nlogn) O(1) Medium Sort, Greedy
3458 Select K Disjoint Special Substrings C++ Python O(n + 26^3) O(26) Medium Hash Table, Sort, Greedy
3462 Maximum Sum With at Most K Elements C++ Python O(n * m) O(1) Medium Greedy, Quick Select
3468 Find the Number of Copy Arrays C++ Python O(n) O(1) Medium Greedy
3474 Lexicographically Smallest Generated String C++ Python O(n + m) O(n + m) Hard KMP Algorithm, Z-Function, Two Pointers, Sliding Window, Deque, Greedy
3476 Maximize Profit from Task Assignment C++ Python O(n + tlogt) O(n) Medium πŸ”’ Freq Table, Sort, Greedy
3478 Choose K Elements With Maximum Sum C++ Python O(nlogn) O(n) Medium Sort, Greedy, Two Pointers, Heap
3480 Maximize Subarrays After Removing One Conflicting Pair C++ Python O(n + m) O(n + m) Hard Greedy
3494 Find the Minimum Amount of Time to Brew Potions C++ Python O(n * m) O(1) Medium Prefix Sum, Greedy
3494 Find the Minimum Amount of Time to Brew Potions C++ Python O(n * m) O(1) Medium Prefix Sum, Greedy
3495 Minimum Operations to Make Array Elements Zero C++ Python O(qlogr) O(1) Hard Greedy
3496 Maximize Score After Pair Deletions C++ Python O(n) O(1) Medium πŸ”’ Greedy
3499 Maximize Active Section with Trade I C++ Python O(n) O(1) Medium Greedy
3501 Maximize Active Section with Trade II C++ Python O(nlogn + q) O(nlogn) Hard Greedy, RMQ, Sparse Table
3506 Find Time Required to Eliminate Bacterial Strains C++ Python O(nlogn) O(1) Hard πŸ”’ Heap, Greedy
3511 Make a Positive Array C++ Python O(n) O(1) Medium πŸ”’ Prefix Sum, Greedy
3517 Smallest Palindromic Rearrangement I C++ Python O(n + 26) O(26) Medium Freq Table, Counting Sort, Greedy
3518 Smallest Palindromic Rearrangement II C++ Python O(26 * n) O(26) Hard Freq Table, Counting Sort, Greedy, Combinatorics
3523 Make Array Non-decreasing C++ Python O(n) O(1) Medium Greedy
3542 Minimum Operations to Convert All Elements to Zero C++ Python O(n) O(n) Medium Greedy, Mono Stack
3545 Minimum Deletions for At Most K Distinct Characters C++ Python O(n + 26) O(n + 26) Easy Freq Table, Counting Sort, Greedy
3557 Find Maximum Number of Non Intersecting Substrings C++ Python O(n) O(26) Medium Greedy, Hash Table
3576 Transform Array to All Equal Elements C++ Python O(n) O(1) Medium Greedy
3587 Minimum Adjacent Swaps to Alternate Parity C++ Python O(n) O(1) Medium Greedy
3627 Maximum Median Sum of Subsequences of Size 3 C++ Python O(nlogn) O(1) Medium Sort, Greedy
3630 Partition Array for Maximum XOR and AND C++ Python O(nlogr * 2^n) O(1) Hard Bitmasks, Greedy
3633 Earliest Finish Time for Land and Water Rides I C++ Python O(n) O(1) Easy Greedy
3635 Earliest Finish Time for Land and Water Rides II C++ Python O(n) O(1) Medium Greedy
3638 Maximum Balanced Shipments C++ Python O(n) O(1) Medium Greedy
3645 Maximum Total from Optimal Activation Order C++ Python O(nlogn) O(n) Medium Sort, Greedy
3675 Minimum Operations to Transform String C++ Python O(n) O(1) Medium Greedy
3681 Maximum XOR of Subsequences C++ Python O(nlogr) O(r) Hard Bitmasks, Greedy
3689 Maximum Total Subarray Value I C++ Python O(n) O(1) Medium Greedy
3711 Maximum Transactions Without Negative Balance C++ Python O(nlogn) O(n) Medium πŸ”’ Greedy, Heap
3720 Lexicographically Smallest Permutation Greater Than Target C++ Python O(26 * n) O(26) Medium Freq Table, Greedy
3723 Maximize Sum of Squares of Digits C++ Python O(n) O(1) Medium Greedy
3724 Minimum Operations to Transform Array C++ Python O(n) O(1) Medium Greedy
3727 Maximum Alternating Sum of Squares C++ Python O(n) O(n) Medium Greedy, Sort, Quick Select
3730 Maximum Calories Burnt from Jumps C++ Python O(nlogn) O(1) Medium πŸ”’ Greedy, Sort
3732 Maximum Product of Three Elements After One Replacement C++ Python O(n) O(1) Medium Greedy
3734 Lexicographically Smallest Palindromic Permutation Greater Than Target C++ Python O(26 * n) O(26) Hard Freq Table, Greedy
3752 Lexicographically Smallest Negated Permutation that Sums to Target C++ Python O(n) O(1) Medium Greedy, Two Pointers
3763 Maximum Total Sum with Threshold Constraints C++ Python O(n) O(n) Medium πŸ”’ Sort, Counting Sort, Greedy
3767 Maximize Points After Choosing K Tasks C++ Python O(n) O(n) Medium Greedy, Sort, Quick Select
3776 Minimum Moves to Balance Circular Array C++ Python O(n) O(1) Medium Greedy
3785 Minimum Swaps to Avoid Forbidden Values C++ Python O(n) O(1) Hard Boyer–Moore Majority Vote Algorithm, Freq Table, Greedy
3796 Find Maximum Value in a Constrained Sequence C++ Python O(n) O(n) Medium Greedy, DP
3797 Count Routes to Climb a Rectangular Grid C++ Python O(n * m) O(m) Hard DP, Two Pointers
3806 Maximum Bitwise AND After Increment Operations C++ Python O(nlogr) O(n) Hard Bitmasks, Greedy, Sort, Quick Select
3812 Minimum Edge Toggles on a Tree C++ Python O(n) O(n) Hard Greedy, Topological Sort, Bitmasks
3816 Lexicographically Smallest String After Deleting Duplicate Characters C++ Python O(n + 26) O(26) Hard Freq Table, Greedy
3828 Final Element After Subarray Deletions C++ Python O(1) O(1) Medium Greedy, Game Theory


Graph

# Title Solution Time Space Difficulty Tag Note
3108 Minimum Cost Walk in Weighted Graph C++ Python O(n + e + q) O(n) Hard Union Find
3112 Minimum Time to Visit Disappearing Nodes C++ Python O(|E| * log|V|) O(|E|) Medium Graph, Dijkstra's Algorithm
3123 Find Edges in Shortest Paths C++ Python O(|E| * log|V|) O(|E|) Hard Graph, Dijkstra's Algorithm
3235 Check if the Rectangle Corner Is Reachable C++ Python O(n^2) O(n) Hard Graph, BFS, DFS, Union Find
3243 Shortest Distance After Road Addition Queries I C++ Python O(n^2) O(n^2) Medium Graph, Dijkstra's Algorithm, BFS
3244 Shortest Distance After Road Addition Queries II C++ Python O(nlogn) O(n) Hard Graph, BST, Sorted List
3265 Count Almost Equal Pairs I C++ Python O(n * l^2) O(n) Medium Freq Table, Combinatorics, Graph, BFS
3267 Count Almost Equal Pairs II C++ Python O(n * l^4) O(n) Hard Freq Table, Combinatorics, Graph, BFS
3276 Select Cells in Grid With Maximum Score C++ Python O(n^2 * max(n, r)) O(n * max(n, r)) Hard variant of Maximum Compatibility Score Sum Hungarian Weighted Bipartite Matching, DP, Bitmasks
3310 Remove Methods From Project C++ Python O(n + e) O(n + e) Medium Graph, BFS
3341 Find Minimum Time to Reach Last Room I C++ Python O(n * m * log(n * m)) O(n * m) Medium Graph, Dijkstra's Algorithm
3342 Find Minimum Time to Reach Last Room II C++ Python O(n * m * log(n * m)) O(n * m) Medium Graph, Dijkstra's Algorithm
3377 Digit Operations to Make Two Integers Equal C++ Python O(nlogn) O(n) Medium Graph, Number Theory, Linear Sieve of Eratosthenes, Dijkstra's Algorithm
3378 Count Connected Components in LCM Graph C++ Python O(n + tlogt) O(t) Hard Number Theory, Graph, Union Find
3383 Minimum Runes to Add to Cast Spell C++ Python O(n) O(n) Hard πŸ”’ Graph, Tarjan's Strongly Connected Components Algorithm, SCC
3376 Minimum Time to Break Locks I C++ Python O(n^3) O(n^2) Medium Bitmasks, DP, Graph, Hungarian Weighted Bipartite Matching
3385 Minimum Time to Break Locks II C++ Python O(n^3) O(n^2) Hard πŸ”’ Graph, Hungarian Weighted Bipartite Matching
3387 Maximize Amount After Two Days of Conversions C++ Python O(n^2) O(n) Medium Bellman-Ford Algorithm, BFS
3419 Minimize the Maximum Edge Weight of Graph C++ Python O(nlogn + e) O(n + e) Medium Graph, Dijkstra's Algorithm, Prim's Algorithm, Binary Search, BFS
3435 Frequencies of Shortest Supersequences C++ Python O(n + k^2 * 2^k) O(k^2) Hard Bitmasks, Graph, Topological Sort
3481 Apply Substitutions C++ Python O(r * 2^r) O(r * 2^r) Medium πŸ”’ Graph, Topological Sort, Memoization
3493 Properties Graph C++ Python O(n^2 * m) O(n) Medium Graph, Flood Fill, BFS, Union Find
3532 Path Existence Queries in a Graph I C++ Python O(n + q) O(n) Medium Prefix Sum
3534 Path Existence Queries in a Graph II C++ Python O((n + q) * logn) O(nlogn) Hard Prefix Sum, Greedy, Binary Lifting
3536 Maximum Product of Two Digits C++ Python O(d + 10) O(10) Easy Freq Table, Greedy
3547 Maximum Sum of Edge Values in a Graph C++ Python O(n) O(n) Hard Flood Fill, BFS, Counting Sort, Greedy
3594 Minimum Time to Transport All Individuals C++ Python O(m * 3^n * log(m * 3^n)) O(m * 3^n) Hard Graph, Dijkstra's Algorithm, Submask Enumeration
3600 Maximize Spanning Tree Stability with Upgrades C++ Python O(n + eloge) O(n) Hard MST, Maximum Spanning Tree, Union Find, Kruskal's Algorithm, Greedy
3604 Minimum Time to Reach Destination in Directed Graph C++ Python O(n + elogn) O(n + e) Medium Graph, Dijkstra's Algorithm
3620 Network Recovery Pathways C++ Python O((n + e) * logr) O(n + e) Hard Binary Search, Topological Sort, DP
3650 Minimum Cost Path with Edge Reversals C++ Python O(n + elogn) O(n + e) Medium Graph, Dijkstra's Algorithm
3656 Determine if a Simple Graph Exists C++ Python O(nlogn) O(1) Medium πŸ”’ Graph, ErdΕ‘s–Gallai Theorem, Sort, Prefix sum, Two Pointers
3660 Jump Game IX C++ Python O(n) O(1) Medium Graph, Prefix Sum
3710 Maximum Partition Factor C++ Python O(n^2 * logn) O(n^2) Hard Graph, Sort, Coordinate Compression, Binary Search, BFS, Greedy, Union Find
3778 Minimum Distance Excluding One Maximum Weighted Edge C++ Python O(n + elogn) O(n + e) Medium πŸ”’ Graph, Dijkstra's Algorithm


Geometry

# Title Solution Time Space Difficulty Tag Note
3453 Separate Squares I C++ Python O(nlogn) O(n) Medium Binary Search, Sort, Line Sweep
3454 Separate Squares II C++ Python O(nlogn) O(n) Hard Sort, Line Sweep, Segment Tree


Simulation

# Title Solution Time Space Difficulty Tag Note
3100 Water Bottles II C++ Python O(sqrt(n)) O(1) Medium Simulation
3168 Minimum Number of Chairs in a Waiting Room C++ Python O(n) O(1) Easy Simulation
3175 Find The First Player to win K Games in a Row C++ Python O(n) O(1) Medium Simulation
3248 Snake in Matrix C++ Python O(c) O(1) Medium Simulation
3412 Find Mirror Score of a String C++ Python O(n + 26) O(n + 26) Medium Simulation, Hash Table, Stack
3433 Count Mentions Per User C++ Python O(eloge + e * n) O(e + n) Medium Simulation
3507 Minimum Pair Removal to Sort Array I C++ Python O(nlogn) O(n) Easy Simulation, Doubly Linked List, Sorted List, BST
3510 Minimum Pair Removal to Sort Array II C++ Python O(nlogn) O(n) Hard Simulation, Doubly Linked List, Sorted List, BST
3522 Calculate Score After Performing Instructions C++ Python O(n) O(n) Medium Simulation
3561 Resulting String After Adjacent Removals C++ Python O(n) O(1) Medium Simulation, Stack
3597 Partition String C++ Python O(n) O(t) Medium Simulation, Trie
3608 Minimum Time for K Connected Components C++ Python O(n + eloge) O(n) Medium Backward Simulation, Sort, Union Find
3609 Minimum Moves to Reach Target in Grid C++ Python O(logtx + logty) O(1) Hard Backward Simulation
3612 Process String with Special Operations I C++ Python O(r) O(r) Medium Simulation, Deque
3613 Minimize Maximum Component Cost C++ Python O(n + eloge) O(n) Medium Backward Simulation, Sort, Union Find
3614 Process String with Special Operations II C++ Python O(n) O(1) Hard Backward Simulation
3616 Number of Student Replacements C++ Python O(n) O(1) Medium πŸ”’ Simulation
3639 Minimum Time to Activate String C++ Python O(n) O(n) Medium Backward Simulation, Doubly Linked List
3792 Sum of Increasing Product Blocks C++ Python O(n^2) O(n^2) Medium πŸ”’ Simulation, Math


Constructive Algorithms

# Title Solution Time Space Difficulty Tag Note
3139 Minimum Cost to Equalize Array C++ Python O(n) O(1) Hard Constructive Algorithms, Math
3260 Find the Largest Palindrome Divisible by K C++ Python O(n) O(1) Hard String, Constructive Algorithms, Math
3311 Construct 2D Grid Matching Graph Layout C++ Python O(n) O(n) Hard Graph, Constructive Algorithms, BFS
3375 Minimum Operations to Make Array Values Equal to K C++ Python O(n) O(n) Easy Hash Table, Constructive Algorithms
3680 Generate Schedule C++ Python O(n^2) O(1) Medium Constructive Algorithms


Design

# Title Solution Time Space Difficulty Tag Note
3242 Design Neighbor Sum Service C++ Python ctor: O(n^2)
adjacentSum: O(1)
diagonalSum: O(1)
O(n^2) Easy Hash Table
3369 Design an Array Statistics Tracker C++ Python ctor: O(1)
addNumber: O(logn)
removeFirstAddedNumber: O(logn)
getMean: O(1)
getMedian: O(1)
getMode: O(1)
O(n) Hard πŸ”’ Deque, Freq Table, Sorted List, BST
3391 Design a 3D Binary Matrix with Efficient Layer Tracking C++ Python ctor: O(1)
setCell: O(logn)
unsetCell: O(logn)
largestMatrix: O(logn)
O(n^3) Medium πŸ”’ Heap, Sorted List
3408 Design Task Manager C++ Python ctor: O(tlogt)
add: O(logt)
edit: O(logt)
rmv: O(logt)
execTop: O(logt)
O(t) Medium Sorted List
3484 Design Spreadsheet C++ Python ctor: O(1)
setCell: O(1)
resetCell: O(1)
getValue: O(1)
O(n) Medium Hash Table
3508 Implement Router C++ Python ctor: O(1)
addPacket: O(logn)
forwardPacket: O(logn)
getCount: O(logn)
O(n) Medium Queue, Sorted List, Ordered Set
3709 Design Exam Scores Tracker C++ Python ctor: O(1)
record: O(1)
totalScore: O(logn)
O(n) Medium Prefix Sum, Binary Search
3815 Design Auction System C++ Python ctor: O(1)
addBid: O(logn)
updateBid: O(logn)
removeBid: O(logn)
getHighestBidder: O(1)
O(n) Medium Hash Table, Heap, Sorted List, BST
3822 Design Order Management System C++ Python ctor: O(1)
addOrder: O(1)
modifyOrder: O(1)
cancelOrder: O(1)
getOrdersAtPrice: O(n)
O(n) Medium πŸ”’ Hash Table
3829 Design Ride Sharing System C++ Python ctor: O(1)
addRider: O(1)
addDriver: O(1)
matchDriverWithRider: O(1)
cancelRider: O(1)
O(n) Medium Ordered Dict


JS

# Title Solution Time Space Difficulty Tag Note


SQL

# Title Solution Time Space Difficulty Tag Note
3050 Pizza Toppings Cost Analysis MySQL O(n^3 * logn) O(n^3) Medium πŸ”’
3051 Find Candidates for Data Scientist Position MySQL O(nlogn) O(n) Easy πŸ”’
3052 Maximize Items MySQL O(n) O(n) Hard πŸ”’
3053 Classifying Triangles by Lengths MySQL O(n) O(n) Easy πŸ”’
3054 Binary Tree Nodes MySQL O(nlogn) O(n) Medium πŸ”’
3055 Top Percentile Fraud MySQL O(nlogn) O(n) Medium πŸ”’
3056 Snaps Analysis MySQL O(n) O(n) Medium πŸ”’
3057 Employees Project Allocation MySQL O(nlogn) O(n) Hard πŸ”’
3058 Friends With No Mutual Friends MySQL O(n^2 * logn) O(n^2) Medium πŸ”’
3059 Find All Unique Email Domains MySQL O(nlogn) O(n) Easy πŸ”’
3060 User Activities within Time Bounds MySQL O(nlogn) O(n) Hard πŸ”’
3061 Calculate Trapping Rain Water MySQL O(nlogn) O(n) Hard πŸ”’
3087 Find Trending Hashtags MySQL O(nlogn) O(n) Medium πŸ”’
3089 Find Bursty Behavior MySQL O(nlogn) O(n) Medium πŸ”’ Window Function
3103 Find Trending Hashtags II MySQL O(n * l^2 + (n * l) * log(n * l)) O(n * l^2) Hard πŸ”’ Recursive CTE
3118 Friday Purchase III MySQL O(n) O(n) Medium πŸ”’
3124 Find Longest Calls MySQL O(nlogn) O(n) Medium πŸ”’ Window Function
3126 Server Utilization Time MySQL O(nlogn) O(n) Medium Window Function
3140 Consecutive Available Seats II MySQL O(nlogn) O(n) Medium πŸ”’ Window Function
3150 Invalid Tweets II MySQL O(n * l + nlogn) O(n * l) Easy πŸ”’ String
3156 Employee Task Duration and Concurrent Tasks MySQL O(nlogn) O(n) Hard πŸ”’ Line Sweep
3166 Calculate Parking Fees and Duration MySQL O(nlogn) O(n) Medium πŸ”’
3172 Second Day Verification MySQL O(nlogn) O(n) Easy πŸ”’
3182 Find Top Scoring Students MySQL O(nlogn) O(n) Medium πŸ”’
3188 Find Top Scoring Students II MySQL O(nlogn) O(n) Hard πŸ”’
3198 Find Cities in Each State MySQL O(nlogn) O(n) Easy πŸ”’
3204 Bitwise User Permissions Analysis MySQL O(n) O(n) Medium πŸ”’
3214 Year on Year Growth Rate MySQL O(nlogn) O(n) Hard πŸ”’ Window Function
3220 Odd and Even Transactions MySQL O(nlogn) O(n) Medium
3230 Customer Purchasing Behavior Analysis MySQL O(nlogn) O(n) Medium πŸ”’ Window Function
3236 CEO Subordinate Hierarchy MySQL O(nlogn) O(n) Hard πŸ”’ Recursive CTE, BFS
3246 Premier League Table Ranking MySQL O(nlogn) O(n) Easy πŸ”’ Window Function
3252 Premier League Table Ranking II MySQL O(nlogn) O(n) Medium πŸ”’ Window Function
3262 Find Overlapping Shifts MySQL O(nlogn) O(n) Medium πŸ”’ Line Sweep
3268 Find Overlapping Shifts II MySQL O(n^2) O(n^2) Hard πŸ”’ Line Sweep, Window Function, Combinatorics
3278 Find Candidates for Data Scientist Position II MySQL O(p * s * n + p * nlogn + plogp) O(p * s * n) Medium πŸ”’ Window Function
3293 Calculate Product Final Price MySQL O(nlogn) O(n) Medium πŸ”’
3308 Find Top Performing Driver MySQL O(tlogt) O(t) Medium πŸ”’ Window Function
3322 Premier League Table Ranking III MySQL O(nlogn) O(n) Medium πŸ”’ Window Function
3328 Find Cities in Each State II MySQL O(nlogn) O(n) Medium πŸ”’
3338 Second Highest Salary II MySQL O(nlogn) O(n) Medium πŸ”’ Window Function
3358 Books with NULL Ratings MySQL O(nlogn) O(n) Easy πŸ”’
3368 First Letter Capitalization MySQL O(n * l^2 + (n * l) * log(n * l)) O(n * l^2) Hard πŸ”’ Recursive CTE
3374 First Letter Capitalization II MySQL O(n * l^2 + (n * l) * log(n * l)) O(n * l^2) Hard πŸ”’ Recursive CTE
3384 Team Dominance by Pass Success MySQL O(plogp + t) O(p + t) Hard πŸ”’
3390 Longest Team Pass Streak MySQL O(plogp + t) O(p + t) Hard πŸ”’ Recursive CTE, Window Function
3401 Find Circular Gift Exchange Chains MySQL O(n^2) O(n^2) Hard πŸ”’ Recursive CTE, Window Function
3415 Find Products with Three Consecutive Digits MySQL O(nlogn) O(n) Easy πŸ”’ Regular Expression
3421 Find Students Who Improved MySQL O(nlogn) O(n) Medium πŸ”’ Window Function
3436 Find Valid Emails MySQL O(n) O(n) Easy Regular Expression
3451 Find Invalid IP Addresses MySQL O(nlogn) O(n) Hard Regular Expression
3465 Find Products with Valid Serial Numbers MySQL O(nlogn) O(n) Easy Regular Expression
3475 DNA Pattern Recognition MySQL O(nlogn) O(n) Medium Regular Expression
3482 Analyze Organization Hierarchy MySQL O(n^2) O(n^2) Hard Recursive CTE, BFS
3497 Analyze Subscription Conversion MySQL O(nlogn) O(n) Medium
3521 Find Product Recommendation Pairs MySQL O(n^2 * logn) O(n^2) Medium
3554 Find Category Recommendation Pairs MySQL O(n^2 * logn) O(n^2) Hard
3564 Seasonal Sales Analysis MySQL O(nlogn) O(n) Medium Window Function
3570 Find Books with No Available Copies MySQL O(nlogn) O(n) Easy
3580 Find Consistently Improving Employees MySQL O(nlogn) O(n) Medium Window Function
3586 Find COVID Recovery Patients MySQL O(n^2) O(n^2) Medium
3601 Find Drivers with Improved Fuel Efficiency MySQL O(nlogn) O(n) Medium
3611 Find Overbooked Employees MySQL O(m + nlogn) O(m + n) Medium
3617 Find Students with Study Spiral Pattern MySQL O(nlogn) O(n) Hard Window Function
3626 Find Stores with Inventory Imbalance MySQL O(n^2 * logn) O(n^2) Medium
3642 Find Books with Polarized Opinions MySQL O(r + nlogn) O(r + n) Easy
3657 Find Loyal Customers MySQL O(nlogn) O(n) Medium
3673 Find Zombie Sessions MySQL O(nlogn) O(n) Hard
3705 Find Golden Hour Customers MySQL O(nlogn) O(n) Medium
3716 Find Churn Risk Customers MySQL O(nlogn) O(n) Medium Window Function
3764 Most Common Course Pairs MySQL O(nlogn) O(n) Hard Window Function
3793 Find Users with High Token Usage MySQL O(nlogn) O(n) Easy
3808 Find Emotionally Consistent Users MySQL O(nlogn) O(n) Medium Window Function
3832 Find Users with Persistent Behavior Patterns MySQL O(nlogn) O(n) Hard Window Function


PD

# Title Solution Time Space Difficulty Tag Note