Skip to content

πŸ‹οΈ Python / Modern C++ Solutions of All 3384 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

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

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
2151 Maximum Good People Based on Statements C++ Python O(n^2 * 2^n) O(1) Hard Bitmasks, Brute Force
2212 Maximum Points in an Archery Competition C++ Python O(n * 2^n) O(n) Medium Bitmasks, Brute Force
2220 Minimum Bit Flips to Convert Number C++ Python O(logn) O(1) Easy Bit Manipulation
2275 Largest Combination With Bitwise AND Greater Than Zero C++ Python O(nlogr) O(logr) Medium Bit Manipulation, Freq Table
2317 Maximum XOR After Operations C++ Python O(n) O(1) Medium Bit Manipulation, Greedy
2397 Maximum Rows Covered by Columns C++ Python O(m * n + m * C(n, k)) O(m) Medium Bitmasks, Hakmem Item 175
2411 Smallest Subarrays With Maximum Bitwise OR C++ Python O(n) O(1) Medium Bitmasks, Hash Table
2419 Longest Subarray With Maximum Bitwise AND C++ Python O(n) O(1) Medium Bit Manipulation
2425 Bitwise XOR of All Pairings C++ Python O(n) O(1) Medium Bit Manipulation
2429 Minimize XOR C++ Python O(logn) O(1) Medium Bit Manipulation, Greedy
2505 Bitwise OR of All Subsequence Sums C++ Python O(n) O(1) Medium πŸ”’ Bit Manipulation
2527 Find Xor-Beauty of Array C++ Python O(n) O(1) Medium Bit Manipulation, Math
2595 Number of Even and Odd Bits C++ Python O(1) O(1) Easy Bit Manipulation
2859 Sum of Values at Indices With K Set Bits C++ Python O(C(ceil(log2(n)), k)) O(1) Easy Bitmasks, Hakmem Item 175
2917 Find the K-or of an Array C++ Python O(nlogr) O(1) Easy Bit Manipulation
2932 Maximum Strong Pair XOR I C++ Python O(nlogr) O(t) Easy variant of Maximum XOR of Two Numbers in an Array Bit Manipulation, Greedy, Trie, DP, Sort, Two Pointers, Brute Force
2935 Maximum Strong Pair XOR II C++ Python O(nlogr) O(t) Hard variant of Maximum XOR of Two Numbers in an Array Bit Manipulation, Greedy, Trie, DP, Sort, Two Pointers
2980 Check if Bitwise OR Has Trailing Zeros C++ Python O(n) O(1) Easy Bit Manipulation
2997 Minimum Number of Operations to Make Array XOR Equal to K C++ Python O(n) O(1) Medium Bit Manipulation
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


Array

# Title Solution Time Space Difficulty Tag Note
2007 Find Original Array From Doubled Array C++ Python O(n + klogk) O(k) Medium variant of Array of Doubled Pairs
2011 Final Value of Variable After Performing Operations C++ Python O(n) O(1) Easy
2012 Sum of Beauty in the Array C++ Python O(n) O(n) Medium Prefix Sum
2016 Maximum Difference Between Increasing Elements C++ Python O(n) O(1) Easy variant of Best Time to Buy and Sell Stock
2017 Grid Game C++ Python O(n) O(1) Medium Prefix Sum
2018 Check if Word Can Be Placed In Crossword C++ Python O(m * n) O(1) Medium
2022 Convert 1D Array Into 2D Array C++ Python O(m * n) O(1) Easy
2033 Minimum Operations to Make a Uni-Value Grid C++ Python O(m * n) on average O(m * n) Medium variant of Minimum Moves to Equal Array Elements II Math, Median, Quick Select
2035 Partition Array Into Two Arrays to Minimize Sum Difference C++ Python O(n * 2^n) O(2^n) Hard Meet in the Middle
2038 Remove Colored Pieces if Both Neighbors are the Same Color C++ Python O(n) O(1) Medium
2055 Plates Between Candles C++ Python O(n + q) O(n) Medium Prefix Sum
2057 Smallest Index With Equal Value C++ Python O(n) O(1) Easy
2075 Decode the Slanted Ciphertext C++ Python O(n) O(1) Medium
2078 Two Furthest Houses With Different Colors C++ Python O(n) O(1) Easy
2079 Watering Plants C++ Python O(n) O(1) Medium
2098 Subsequence of Size K With the Largest Even Sum C++ Python O(n) on average O(1) Medium πŸ”’ Quick Select
2099 Find Subsequence of Length K With the Largest Sum C++ Python O(n) on average O(n) Easy Quick Select
2100 Find Good Days to Rob the Bank C++ Python O(n) O(n) Medium Prefix Sum
2106 Maximum Fruits Harvested After at Most K Steps C++ Python O(n) O(n) Hard Prefix Sum
2113 Elements in Array After Removing and Replacing Elements C++ Python O(n) O(1) Medium πŸ”’
2121 Intervals Between Identical Elements C++ Python O(n) O(n) Medium Prefix Sum
2122 Recover the Original Array C++ Python O(n^2) O(n) Hard
2128 Remove All Ones With Row and Column Flips C++ Python O(m * n) O(1) Medium πŸ”’
2132 Stamping the Grid C++ Python O(m * n) O(m * n) Hard Prefix Sum
2155 All Divisions With the Highest Score of a Binary Array C++ Python O(n) O(1) Medium Prefix Sum
2194 Cells in a Range on an Excel Sheet C++ Python O(26^2) O(1) Easy
2210 Count Hills and Valleys in an Array C++ Python O(n) O(1) Easy Simulation
2219 Maximum Sum Score of Array C++ Python O(n) O(1) Medium πŸ”’ Prefix Sum
2237 Count Positions on Street With Required Brightness C++ Python O(n + l) O(min(n, l)) Medium πŸ”’ Line Sweep
2239 Find Closest Number to Zero C++ Python O(n) O(1) Easy Array
2245 Maximum Trailing Zeros in a Cornered Path C++ Python O(m * n) O(m * n) Medium Prefix Sum
2256 Minimum Average Difference C++ Python O(n) O(1) Medium Prefix Sum
2270 Number of Ways to Split Array C++ Python O(n) O(1) Medium Prefix Sum
2271 Maximum White Tiles Covered by a Carpet C++ Python O(nlogn) O(1) Medium Sliding Window, Prefix Sum, Binary Search
2274 Maximum Consecutive Floors Without Special Floors C++ Python O(nlogn) O(1) Medium Sort
2293 Min Max Game C++ Python O(n) O(1) Medium Simulation
2319 Check if Matrix Is X-Matrix C++ Python O(n^2) O(1) Easy Array
2326 Spiral Matrix IV C++ Python O(m * n) O(1) Medium Linked List, Array
2373 Largest Local Values in a Matrix C++ Python O(n^2) O(1) Easy Array
2382 Maximum Segment Sum After Removals C++ Python O(n) O(n) Hard Prefix Sum, Sorted List, BST, Union Find
2391 Minimum Amount of Time to Collect Garbage C++ Python O(n * l) O(1) Medium Prefix Sum, Simulation
2406 Divide Intervals Into Minimum Number of Groups C++ Python O(nlogn) O(n) Medium Sort, Line Sweep
2407 Longest Increasing Subsequence II C++ Python O(nlogn) O(n) Hard variant of Longest Increasing Subsequence Segment Tree, Coordinate Compression
2428 Maximum Sum of an Hourglass C++ Python O(m * n) O(1) Medium Brute Force
2432 The Employee That Worked on the Longest Task C++ Python O(l) O(1) Easy Array
2433 Find The Original Array of Prefix Xor C++ Python O(n) O(1) Medium Array
2438 Range Product Queries of Powers C++ Python O(logn + qlogr) O(logn) Medium Prefix Sum
2446 Determine if Two Events Have Conflict C++ Python O(1) O(1) Easy Array
2460 Apply Operations to an Array C++ Python O(n) O(1) Easy Inplace, Array
2482 Difference Between Ones and Zeros in Row and Column C++ Python O(m * n) O(m + n) Medium Array
2500 Delete Greatest Value in Each Row C++ Python O(m * nlogn) O(1) Easy Array
2515 Shortest Distance to Target String in a Circular Array C++ Python O(n) O(1) Easy Array
2535 Difference Between Element Sum and Digit Sum of an Array C++ Python O(nlogr) O(1) Easy Array
2536 Increment Submatrices by One C++ Python O(q + n^2) O(1) Medium Line Sweep, Difference Matrix, Difference Array
2553 Separate the Digits in an Array C++ Python O(n * logr) O(1) Easy Array
2559 Count Vowel Strings in Ranges C++ Python O(n + q) O(n) Medium Prefix Sum
2569 Handling Sum Queries After Update C++ Python O(nlogn + m + qlogn) O(n) Hard Segment Tree
2574 Left and Right Sum Differences C++ Python O(n) O(1) Easy Prefix Sum
2580 Count Ways to Group Overlapping Ranges C++ Python O(nlogn) O(1) Medium Sort, Array
2639 Find the Width of Columns of a Grid C++ Python O(m * n) O(1) Easy Array
2640 Find the Score of All Prefixes of an Array C++ Python O(n) O(1) Medium Prefix Sum
2643 Row With Maximum Ones C++ Python O(m * n) O(1) Easy Array
2644 Find the Maximum Divisibility Score C++ Python O(n * d) O(1) Easy Brute force
2655 Find Maximal Uncovered Ranges C++ Python O(nlogn) O(n) Medium πŸ”’, variant of Merge Intervals Sort, Line Sweep
2660 Determine the Winner of a Bowling Game C++ Python O(n) O(1) Medium Array
2672 Number of Adjacent Elements With the Same Color C++ Python O(n + q) O(n) Medium Array
2683 Neighboring Bitwise XOR C++ Python O(n) O(1) Medium Array
2711 Difference of Number of Distinct Values on Diagonals C++ Python O(m * n) O(min(m, n)) Medium Prefix Sum
2717 Semi-Ordered Permutation C++ Python O(n) O(1) Easy Array
2733 Neither Minimum nor Maximum C++ Python O(n) O(1) Easy Array
2760 Longest Even Odd Subarray With Threshold C++ Python O(n) O(1) Easy Array
2765 Longest Alternating Subarray C++ Python O(n) O(1) Easy Array
2782 Number of Unique Categories C++ Python O(n^2) O(1) Medium πŸ”’ Brute Force
2798 Number of Employees Who Met the Target C++ Python O(n) O(1) Easy Array
2848 Points That Intersect With Cars C++ Python O(nlogn) O(1) Easy Sort, Line Sweep
2855 Minimum Right Shifts to Sort the Array C++ Python O(n) O(1) Easy Array
2873 Maximum Value of an Ordered Triplet I C++ Python O(n) O(1) Easy Array
2874 Maximum Value of an Ordered Triplet II C++ Python O(n) O(1) Easy Array
2903 Find Indices With Index and Value Difference I C++ Python O(n) O(1) Easy Prefix Sum
2905 Find Indices With Index and Value Difference II C++ Python O(n) O(1) Medium Prefix Sum
2906 Construct Product Matrix C++ Python O(m * n) O(m * n) Medium Prefix Sum
2908 Minimum Sum of Mountain Triplets I C++ Python O(n) O(n) Easy Prefix Sum
2909 Minimum Sum of Mountain Triplets II C++ Python O(n) O(n) Medium Prefix Sum
2923 Find Champion I C++ Python O(n^2) O(1) Easy Array
2946 Matrix Similarity After Cyclic Shifts C++ Python O(m * n) O(1) Easy Array
2951 Find the Peaks C++ Python O(n) O(1) Easy Array
2965 Find Missing and Repeated Values C++ Python O(n^2) O(1) Easy Array, Freq Table, Bit Manipulation
2966 Divide Array Into Arrays With Max Difference C++ Python O(nlogn) O(1) Medium Sort, Array
3000 Maximum Area of Longest Diagonal Rectangle C++ Python O(n) O(1) Easy Array
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


String

# Title Solution Time Space Difficulty Tag Note
2042 Check if Numbers Are Ascending in a Sentence C++ Python O(n) O(1) Easy
2047 Number of Valid Words in a Sentence C++ Python O(n) O(1) Easy
2048 Next Greater Numerically Balanced Number C++ Python O(1) O(1) Medium Permutations, Precompute, Binary Search
2081 Sum of k-Mirror Numbers C++ Python O(10^6) O(1) Hard String, Palindrome, Brute Force
2103 Rings and Rods C++ Python O(n) O(1) Easy
2108 Find First Palindromic String in the Array C++ Python O(n) O(1) Easy
2109 Adding Spaces to a String C++ Python O(n) O(1) Medium Inplace
2114 Maximum Number of Words Found in Sentences C++ Python O(n) O(1) Easy
2116 Check if a Parentheses String Can Be Valid C++ Python O(n) O(1) Medium
2124 Check if All A's Appears Before All B's C++ Python O(n) O(1) Easy
2129 Capitalize the Title C++ Python O(n) O(1) Easy
2131 Longest Palindrome by Concatenating Two Letter Words C++ Python O(n) O(n) Medium
2135 Count Words Obtained After Adding a Letter C++ Python O(n) O(n) Medium Bitmasks
2138 Divide a String Into Groups of Size k C++ Python O(n) O(1) Easy
2156 Find Substring With Given Hash Value C++ Python O(n) O(1) Medium Rabin-Karp Algorithm, Rolling Hash
2157 Groups of Strings C++ Python O(26 * n) O(26 * n) Hard Bitmasks, Union Find
2168 Unique Substrings With Equal Digit Frequency C++ Python O(n^2) O(n^2) Medium πŸ”’ Rabin-Karp Algorithm, Rolling Hash
2185 Counting Words With a Given Prefix C++ Python O(n * p) O(1) Easy
2186 Minimum Number of Steps to Make Two Strings Anagram II C++ Python O(n) O(1) Medium variant of Minimum Number of Steps to Make Two Strings Anagram
2211 Count Collisions on a Road C++ Python O(n) O(1) Medium Counting, Simulation
2213 Longest Substring of One Repeating Character C++ Python O(nlogn) O(n) Hard Segment Tree
2223 Sum of Scores of Built Strings C++ Python O(n) O(n) Hard Z-Function
2232 Minimize Result by Adding Parentheses to Expression C++ Python O(n^2) O(1) Medium Brute Force
2243 Calculate Digit Sum of a String C++ Python O(n) O(n) Easy Simulation
2255 Count Prefixes of a Given String C++ Python O(n * l) O(1) Easy String
2264 Largest 3-Same-Digit Number in String C++ Python O(n) O(1) Easy String
2269 Find the K-Beauty of a Number C++ Python O(logn) O(logn) Easy Sliding Window
2272 Substring With Largest Variance C++ Python O(a^2 * n) O(a) Hard Kadane's Algorithm
2273 Find Resultant Array After Removing Anagrams C++ Python O(n * l) O(1) Easy Freq Table, Sort
2278 Percentage of Letter in String C++ Python O(n) O(1) Easy String
2288 Apply Discount to Prices C++ Python O(n) O(1) Medium String
2299 Strong Password Checker II C++ Python O(n) O(1) Easy String
2301 Match Substring After Replacement C++ Python O(n * k) O(m) Hard Brute Force
2315 Count Asterisks C++ Python O(n) O(1) Easy String
2381 Shifting Letters II C++ Python O(n) O(n) Medium Line Sweep
2390 Removing Stars From a String C++ Python O(n) O(n) Medium String, Stack
2414 Length of the Longest Alphabetical Continuous Substring C++ Python O(n) O(1) Medium String
2416 Sum of Prefix Scores of Strings C++ Python O(n * l) O(t) Hard Trie
2490 Circular Sentence C++ Python O(n) O(1) Easy String
2496 Maximum Value of a String in an Array C++ Python O(n * l) O(1) Easy String
2575 Find the Divisibility Array of a String C++ Python O(n) O(1) Medium Prefix Sum
2586 Count the Number of Vowel Strings in Range C++ Python O(n) O(1) Medium String
2678 Number of Senior Citizens C++ Python O(n) O(1) Easy String
2710 Remove Trailing Zeros From a String C++ Python O(n) O(1) Easy String
2729 Check if The Number is Fascinating C++ Python O(logn) O(1) Easy String, Bitmasks
2788 Split Strings by Separator C++ Python O(n * l) O(l) Easy String
2800 Shortest String That Contains Three Strings C++ Python O(l) O(l) Medium String, Brute Force, Longest Prefix Suffix, KMP Algorithm
2810 Faulty Keyboard C++ Python O(n) O(n) Easy String, Deque
2828 Check if a String Is an Acronym of Words C++ Python O(n) O(1) Easy String
2843 Count Symmetric Integers C++ Python O(rlogr) O(r) Easy String, Brute Force, Memoization
2851 String Transformation C++ Python O(n + logk) O(n) Hard DP, Matrix Exponentiation, Math, Z-Function, KMP Algorithm
2937 Make Three Strings Equal C++ Python O(n) O(1) Easy String
2942 Find Words Containing Character C++ Python O(n * l) O(1) Easy String
2967 Minimum Cost to Make Array Equalindromic C++ Python O(n + logr) O(logr) Medium variant of Find the Closest Palindrome Sort, Quick Select, Math, String
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


Linked List

# Title Solution Time Space Difficulty Tag Note
2058 Find the Minimum and Maximum Number of Nodes Between Critical Points C++ Python O(n) O(1) Medium
2074 Reverse Nodes in Even Length Groups C++ Python O(n) O(1) Medium
2095 Delete the Middle Node of a Linked List C++ Python O(n) O(1) Medium Two Pointers
2130 Maximum Twin Sum of a Linked List C++ Python O(n) O(1) Medium Two Pointers
2181 Merge Nodes in Between Zeros C++ Python O(n) O(1) Medium Two Pointers
2487 Remove Nodes From Linked List C++ Python O(n) O(n) Medium Mono Stack
2674 Split a Circular Linked List C++ Python O(n) O(1) Medium πŸ”’ Two Pointers, Slow and Fast Pointers
2807 Insert Greatest Common Divisors in Linked List C++ Python O(n) O(1) Medium Linked List
2816 Double a Number Represented as a Linked List C++ Python O(n) O(1) Medium Linked List
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
2104 Sum of Subarray Ranges C++ Python O(n) O(n) Medium Mono Stack
2197 Replace Non-Coprime Numbers in Array C++ Python O(nlogm) O(1) Hard Stack, Math
2281 Sum of Total Strength of Wizards C++ Python O(n) O(n) Hard variant of Largest Rectangle in Histogram Mono Stack, Prefix Sum
2282 Number of People That Can Be Seen in a Grid C++ Python O(m * n) O(m + n) Medium πŸ”’, variant of Number of Visible People in a Queue Mono Stack
2334 Subarray With Elements Greater Than Varying Threshold C++ Python O(n) O(n) Hard variant of Maximum Subarray Min-Product Mono Stack
2355 Maximum Number of Books You Can Take C++ Python O(n) O(n) Hard πŸ”’ Mono Stack, Math
2454 Next Greater Element IV C++ Python O(n) O(n) Hard Mono Stack
2696 Minimum String Length After Removing Substrings C++ Python O(n) O(n) Easy Stack
2735 Collecting Chocolates C++ Python O(n) O(n) Medium Mono Stack, Difference Array, Prefix Sum, Binary Search, Mono Deque, Brute Force
2736 Maximum Sum Queries C++ Python O(nlogn + mlogm + mlogn) O(n + m) Hard Sort, Mono Stack, Binary Search
2764 is Array a Preorder of Some β€ŒBinary Tree C++ Python O(n) O(n) Medium πŸ”’ Stack
2832 Maximal Range That Each Element Is Maximum in It C++ Python O(n) O(n) Medium πŸ”’ Mono Stack
2863 Maximum Length of Semi-Decreasing Subarrays C++ Python O(n) O(n) Medium πŸ”’ Sort, Mono Stack
2865 Beautiful Towers I C++ Python O(n) O(n) Medium Mono Stack
2866 Beautiful Towers II C++ Python O(n) O(n) Medium Mono Stack
2899 Last Visited Integers C++ Python O(n) O(n) Easy Stack
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


Queue

# Title Solution Time Space Difficulty Tag Note
2398 Maximum Number of Robots Within Budget C++ Python O(n) O(n) Hard Mono Deque, Sliding Window, Two Pointers


Binary Heap

# Title Solution Time Space Difficulty Tag Note
2054 Two Best Non-Overlapping Events C++ Python O(nlogn) O(n) Medium Line Sweep, Heap
2163 Minimum Difference in Sums After Removal of Elements C++ Python O(nlogn) O(n) Hard Heap, Prefix Sum
2208 Minimum Operations to Halve Array Sum C++ Python O(nlogn) O(n) Medium Heap
2386 Find the K-Sum of an Array C++ Python O(nlogn + klogk) O(n + k) Hard BFS, Heap
2402 Meeting Rooms III C++ Python O(mlogm + n + mlogn) O(n) Hard Heap
2462 Total Cost to Hire K Workers C++ Python O(c + klogc) O(c) Medium Heap, Two Pointers
2519 Count the Number of K-Big Indices C++ Python O(nlogk) O(n) Hard πŸ”’ Heap, Ordered Set, Sorted List
2530 Maximal Score After Applying K Operations C++ Python O(n + klogn) O(1) Medium Heap, Simulation
2558 Take Gifts From the Richest Pile C++ Python O(n + klogn) O(1) Easy Heap, Simulation
2818 Apply Operations to Maximize Score C++ Python O(sqrt(r) + n * (logr + sqrt(r)/log(sqrt(r))) + klogn) O(sqrt(r) + n) Hard Number Theory, Linear Sieve of Eratosthenes, Mono Stack, Greedy, Sort, Heap
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


Tree

# Title Solution Time Space Difficulty Tag Note
2003 Smallest Missing Genetic Value in Each Subtree C++ Python O(n) O(n) Hard DFS, Stack
2096 Step-By-Step Directions From a Binary Tree Node to Another C++ Python O(n) O(h) Medium DFS, Stack
2179 Count Good Triplets in an Array C++ Python O(nlogn) O(n) Hard variant of Create Sorted Array through Instructions BIT, Fenwick Tree
2196 Create Binary Tree From Descriptions C++ Python O(n) O(n) Medium
2236 Root Equals Sum of Children C++ Python O(1) O(1) Easy Tree
2277 Closest Node to Path in Tree C++ Python O(n + q) O(n + q) Hard πŸ”’ Tree, BFS, Binary Lifting, Tarjan's Offline LCA Algorithm
2421 Number of Good Paths C++ Python O(nlogn) O(n) Hard Sort, Union Find
2509 Cycle Length Queries in a Tree C++ Python O(q * n) O(1) Hard Tree, LCA
2846 Minimum Edge Weight Equilibrium Queries in a Tree C++ Python O(r * (n + q)) O(r * n + q) Hard Tree, Binary Lifting, Tarjan's Offline LCA Algorithm
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


Hash Table

# Title Solution Time Space Difficulty Tag Note
2006 Count Number of Pairs With Absolute Difference K C++ Python O(n) O(n) Easy variant of Two Sum
2023 Number of Pairs of Strings With Concatenation Equal to Target C++ Python O(n * l) O(n) Medium variant of Two Sum
2025 Maximum Number of Ways to Partition an Array C++ Python O(n) O(n) Hard Prefix Sum
2032 Two Out of Three C++ Python O(n) O(min(n, r)) Easy Counting
2053 Kth Distinct String in an Array C++ Python O(n) O(n) Easy
2068 Check Whether Two Strings are Almost Equivalent C++ Python O(n) O(1) Easy
2085 Count Common Words With One Occurrence C++ Python O(m + n) O(m + n) Easy
2120 Execution of All Suffix Instructions Staying in a Grid C++ Python O(m) O(m) Medium
2150 Find All Lonely Numbers in the Array C++ Python O(n) O(n) Medium
2154 Keep Multiplying Found Values by Two C++ Python O(n) O(n) Easy
2170 Minimum Operations to Make the Array Alternating C++ Python O(n) O(n) Medium Freq Table
2190 Most Frequent Number Following Key In an Array C++ Python O(n) O(n) Easy Freq Table
2201 Count Artifacts That Can Be Extracted C++ Python O(a + d) O(d) Medium Hash Table
2206 Divide Array Into Equal Pairs C++ Python O(n) O(n) Easy Hash Table
2215 Find the Difference of Two Arrays C++ Python O(n) O(n) Easy Hash Table
2225 Find Players With Zero or One Losses C++ Python O(nlogn) O(n) Medium Hash Table, Sort
2229 Check if an Array Is Consecutive C++ Python O(n) O(n) Easy πŸ”’ Hash Table, Sort
2260 Minimum Consecutive Cards to Pick Up C++ Python O(n) O(n) Medium Hash Table
2261 K Divisible Elements Subarrays C++ Python O(n^2) O(t) Medium Trie, Rabin-Karp Algorithm
2283 Check if Number Has Equal Digit Count and Digit Value C++ Python O(n) O(1) Easy Freq Table
2284 Sender With Largest Word Count C++ Python O(n * l) O(n) Medium Freq Table
2287 Rearrange Characters to Make Target String C++ Python O(n + m) O(1) Easy Freq Table
2295 Replace Elements in an Array C++ Python O(n + m) O(n) Medium Hash Table
2306 Naming a Company C++ Python O(26 * n * l) O(n * l) Hard Hash Table, Math
2309 Greatest English Letter in Upper and Lower Case C++ Python O(n) O(1) Easy Freq Table, Hash Table
2325 Decode the Message C++ Python O(n + m) O(1) Easy String, Hash Table
2341 Maximum Number of Pairs in Array C++ Python O(n) O(r) Easy Freq Table
2342 Max Sum of a Pair With Equal Sum of Digits C++ Python O(nlogr) O(n) Medium Hash Table, Greedy
2347 Best Poker Hand C++ Python O(1) O(1) Easy Freq Table
2351 First Letter to Appear Twice C++ Python O(n) O(1) Easy String, Hash Table
2352 Equal Row and Column Pairs C++ Python O(n^2) O(n^2) Medium Hash Table
2354 Number of Excellent Pairs C++ Python O(n) O(n) Hard Bit Manipulation, Sort, Two Pointers, Freq Table, Combinatorics
2357 Make Array Zero by Subtracting Equal Amounts C++ Python O(n) O(n) Easy Hash Table
2363 Merge Similar Items C++ Python O((m + n) * log(m + n)) O(m + n) Easy Freq Table, Sort
2364 Count Number of Bad Pairs C++ Python O(n) O(n) Medium variant of Count Nice Pairs in an Array Hash Table
2365 Task Scheduler II C++ Python O(n) O(n) Medium Hash Table
2367 Number of Arithmetic Triplets C++ Python O(n) O(n) Easy Hash Table
2374 Node With Highest Edge Score C++ Python O(n) O(n) Medium Hash Table
2395 Find Subarrays With Equal Sum C++ Python O(n) O(n) Easy Hash Table
2399 Check Distances Between Same Letters C++ Python O(n) O(1) Easy Hash Table
2404 Most Frequent Even Element C++ Python O(n) O(n) Easy Freq Table
2423 Remove Letter To Equalize Frequency C++ Python O(n) O(1) Easy Brute Force, Freq Table
2441 Largest Positive Integer That Exists With Its Negative C++ Python O(n) O(n) Easy Hash Table
2442 Count Number of Distinct Integers After Reverse Operations C++ Python O(nlogr) O(n) Medium Hash Table
2451 Odd String Difference C++ Python O(m * n) O(1) Easy Freq Table
2452 Words Within Two Edits of Dictionary C++ Python O(25 * l * (n + q)) O(25 * l * n) Medium variant of MHC2022 - Round 3 Brute Force, Hash
2453 Destroy Sequential Targets C++ Python O(n) O(s) Medium Freq Table
2456 Most Popular Video Creator C++ Python O(n) O(n) Medium Hash Table
2484 Count Palindromic Subsequences C++ Python O(100 * n) O(100 * n) Hard Freq Table, Prefix Sum, DP
2488 Count Subarrays With Median K C++ Python O(n) O(n) Hard Freq Table, Prefix Sum
2489 Number of Substrings With Fixed Ratio C++ Python O(n) O(n) Medium πŸ”’ Freq Table, Prefix Sum
2491 Divide Players Into Teams of Equal Skill C++ Python O(n) O(n) Medium Freq Table
2501 Longest Square Streak in an Array C++ Python O(nlogn) O(n) Medium Hash Table, DP
2506 Count Pairs Of Similar Strings C++ Python O(n * l) O(n) Easy Freq Table, Bitmask
2531 Make Number of Distinct Characters Equal C++ Python O(m + n) O(1) Medium Freq Table
2564 Substring XOR Queries C++ Python O(n * logr + q) O(min(n * logr, r)) Medium Hash Table
2588 Count the Number of Beautiful Subarrays C++ Python O(n) O(n) Medium Freq Table, Combinatorics
2592 Maximize Greatness of an Array C++ Python O(n) O(n) Medium Freq Table, Contructive Algorithms, Sort, Greedy, Two Pointers
2598 Smallest Missing Non-negative Integer After Operations C++ Python O(n) O(k) Medium Freq Table
2605 Form Smallest Number From Two Digit Arrays C++ Python O(m + n) O(m + n) Easy Hash Table
2615 Sum of Distances C++ Python O(n) O(n) Medium Freq Table, Prefix Sum
2657 Find the Prefix Common Array of Two Arrays C++ Python O(n) O(n) Medium Freq Table
2661 First Completely Painted Row or Column C++ Python O(m * n) O(m * n) Medium Hash Table
2670 Find the Distinct Difference Array C++ Python O(n) O(n) Easy Hash Table, Prefix Sum
2716 Minimize String Length C++ Python O(n) O(1) Easy Hash Table
2718 Sum of Matrix After Queries C++ Python O(n + q) O(n) Medium Hash Table
2744 Find Maximum Number of String Pairs C++ Python O(n) O(1) Easy Hash Table
2748 Number of Beautiful Pairs C++ Python O(nlogr) O(1) Easy Number Theory, Freq Table
2766 Relocate Marbles C++ Python O(nlogn) O(n) Medium Hash Table, Sort
2768 Number of Black Blocks C++ Python O(c) O(c) Medium Freq Table
2784 Check if Array is Good C++ Python O(n) O(n) Easy Freq Table
2808 Minimum Seconds to Equalize a Circular Array C++ Python O(n) O(n) Medium Hash Table
2815 Max Pair Sum in an Array C++ Python O(nlogr) O(1) Easy Hash Table
2839 Check if Strings Can be Made Equal With Operations I C++ Python O(1) O(1) Easy Brute Force, Freq Table
2840 Check if Strings Can be Made Equal With Operations II C++ Python O(1) O(1) Medium Freq Table
2845 Count of Interesting Subarrays C++ Python O(n) O(m) Medium Freq Table, Prefix Sum
2857 Count Pairs of Points With Distance k C++ Python O(n * k) O(n) Medium Freq Table
2869 Minimum Operations to Collect Elements C++ Python O(n) O(k) Easy Hash Table
2943 Maximize Area of Square Hole in Grid C++ Python O(h + v) O(h + v) Medium Array, Sort, Hash Table
2947 Count Beautiful Substrings I C++ Python O(n + sqrt(k)) O(n) Medium Brute Force, Number Theory, Prefix Sum, Freq Table
2949 Count Beautiful Substrings II C++ Python O(n + sqrt(k)) O(n) Hard Brute Force, Number Theory, Prefix Sum, Freq Table
2950 Number of Divisible Substrings C++ Python O(d * n) O(n) Medium πŸ”’ Prefix Sum, Freq Table
2955 Number of Same-End Substrings C++ Python O(26 * (n + q)) O(26 * n) Medium πŸ”’ Freq Table, Prefix Sum
2956 Find Common Elements Between Two Arrays C++ Python O(n + m) O(n + m) Easy Hash Table
2964 Number of Divisible Triplet Sums C++ Python O(n^2) O(n) Medium πŸ”’ Freq Table
2975 Maximum Square Area by Removing Fences From a Field C++ Python O(h^2 + v^2) O(min(h, v)^2) Medium Hash Table
2981 Find Longest Special Substring That Occurs Thrice I C++ Python O(26 * 3 + n * 3) O(26 * 3) Medium String, Brute Force, Freq Table, Hash Table
2982 Find Longest Special Substring That Occurs Thrice II C++ Python O(26 * 3 + n * 3) O(26 * 3) Medium String, Hash Table
2983 Palindrome Rearrangement Queries C++ Python O(26 + d * n + d * q) O(26 + d * n) Hard Prefix Sum, Freq Table
2996 Smallest Missing Integer Greater Than Sequential Prefix Sum C++ Python O(n) O(n) Easy Hash Table
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


Math

# Title Solution Time Space Difficulty Tag Note
2001 Number of Pairs of Interchangeable Rectangles C++ Python O(n) O(n) Medium Math
2005 Subtree Removal Game with Fibonacci Tree C++ Python O(1) O(1) Hard πŸ”’ Math, Sprague-Grundy Theorem, Colon Principle
2028 Find Missing Observations C++ Python O(n) O(1) Medium
2029 Stone Game IX C++ Python O(n) O(1) Medium
2063 Vowels of All Substrings C++ Python O(n) O(1) Medium Combinatorics
2073 Time Needed to Buy Tickets C++ Python O(n) O(1) Easy Simulation, Math
2083 Substrings That Begin and End With the Same Letter C++ Python O(n) O(1) Medium πŸ”’ Combinatorics
2091 Removing Minimum and Maximum From Array C++ Python O(n) O(1) Medium Math
2110 Number of Smooth Descent Periods of a Stock C++ Python O(n) O(1) Medium Math, Combinatorics
2117 Abbreviating the Product of a Range C++ Python O(r - l) O(1) Hard Math
2119 A Number After a Double Reversal C++ Python O(1) O(1) Easy Math
2125 Number of Laser Beams in a Bank C++ Python O(m * n) O(1) Medium Math
2133 Check if Every Row and Column Contains All Numbers C++ Python O(n^2) O(n) Easy Math
2145 Count the Hidden Sequences C++ Python O(n) O(1) Medium Math
2148 Count Elements With Strictly Smaller and Greater Elements C++ Python O(n) O(1) Easy Math
2152 Minimum Number of Lines to Cover Points C++ Python O(n * 2^n) O(n^2) Medium πŸ”’ Math, Hash Table, Bitmasks
2169 Count Operations to Obtain Zero C++ Python O(log(min(m, n))) O(1) Easy Math, Euclidean Algorithm
2171 Removing Minimum Number of Magic Beans C++ Python O(nlogn) O(1) Medium Math, Sort
2176 Count Equal and Divisible Pairs in an Array C++ Python O(nlogk + n * sqrt(k)) O(n + sqrt(k)) Easy Math
2177 Find Three Consecutive Integers That Sum to a Given Number C++ Python O(1) O(1) Medium Math
2180 Count Integers With Even Digit Sum C++ Python O(logn) O(1) Easy Math
2183 Count Array Pairs Divisible by K C++ Python O(nlogk + k) O(sqrt(k)) Hard variant of Count Equal and Divisible Pairs in an Array Math
2198 Number of Single Divisor Triplets C++ Python O(d^3) O(d) Medium πŸ”’ Math, Combinatorics
2217 Find Palindrome With Fixed Length C++ Python O(n * l) O(1) Medium Math
2221 Find Triangular Sum of an Array C++ Python O(n) O(1) Medium Simulation, Combinatorics, Number Thoery
2235 Add Two Integers C++ Python O(1) O(1) Easy Math
2240 Number of Ways to Buy Pens and Pencils C++ Python O(sqrt(t)) O(1) Medium Math
2244 Minimum Rounds to Complete All Tasks C++ Python O(n) O(n) Medium Math, Freq Table
2249 Count Lattice Points Inside a Circle C++ Python O(n * r^2) O(min(n * r^2, max_x * max_y)) Medium Math, Hash Table
2262 Total Appeal of A String C++ Python O(n) O(26) Hard variant of Count Unique Characters of All Substrings of a Given String Combinatorics
2280 Minimum Lines to Represent a Line Chart C++ Python O(nlogn) O(1) Medium Sort, Math, GCD
2310 Sum of Numbers With Units Digit K C++ Python O(1) O(1) Medium Math
2338 Count the Number of Ideal Arrays C++ Python O(sqrt(m) + n + m * (logm + sqrt(m)/log(sqrt(m)))) O(sqrt(m) + n + logm) Hard variant of Count Ways to Make Array With Product DP, Linear Sieve of Eratosthenes, Factorization, Combinatorics
2344 Minimum Deletions to Make Array Divisible C++ Python O(n + m + logr) O(1) Hard Math, GCD
2345 Finding the Number of Visible Mountains C++ Python O(nlogn) O(1) Medium πŸ”’ Math, Sort, Mono Stack
2376 Count Special Integers C++ Python O(logn) O(logn) Hard variant of Numbers With Repeated Digits Combinatorics
2396 Strictly Palindromic Number C++ Python O(1) O(1) Medium Math
2400 Number of Ways to Reach a Position After Exactly k Steps C++ Python O(k) O(k) Medium Combinatorics
2409 Count Days Spent Together C++ Python O(1) O(1) Easy String, Math, Prefix Sum
2413 Smallest Even Multiple C++ Python O(1) O(1) Easy Math, Bit Manipulation
2427 Number of Common Factors C++ Python O(log(min(a, b)) + sqrt(gcd)) O(1) Easy Math
2437 Number of Valid Clock Times C++ Python O(1) O(1) Easy Combinatorics
2450 Number of Distinct Binary Strings After Applying Operations C++ Python O(logn) O(1) Medium πŸ”’ Combinatorics
2455 Average Value of Even Numbers That Are Divisible by Three C++ Python O(n) O(1) Easy Math
2468 Split Message Based on Limit C++ Python O(n + rlogr) O(1) Hard Brute Force, Math
2469 Convert the Temperature C++ Python O(1) O(1) Easy Math
2481 Minimum Cuts to Divide a Circle C++ Python O(1) O(1) Easy Math
2485 Find the Pivot Integer C++ Python O(1) O(1) Easy Math
2514 Count Anagrams C++ Python O(n) O(n) Hard Math, Combinatorics
2520 Count the Digits That Divide a Number C++ Python O(logn) O(1) Easy Math
2521 Distinct Prime Factors of Product of Array C++ Python precompute: O(sqrt(MAX_N))
runtime: O(m + nlog(logn))
O(sqrt(MAX_N)) Medium Number Theory, Linear Sieve of Eratosthenes
2523 Closest Prime Numbers in Range C++ Python precompute: O(MAX_N * log(MAX_N))
runtime: O(log(MAX_N))
O(MAX_N) Medium Number Theory, Linear Sieve of Eratosthenes, Segment Tree
2525 Categorize Box According to Criteria C++ Python O(1) O(1) Easy Math
2539 Count the Number of Good Subsequences C++ Python O(26 * n) O(n) Medium πŸ”’ Combinatorics
2543 Check if Point Is Reachable C++ Python O(log(min(a, b))) O(1) Hard Number Theory
2544 Alternating Digit Sum C++ Python O(logn) O(1) Easy Math
2549 Count Distinct Numbers on Board C++ Python O(1) O(1) Easy Math
2550 Count Collisions of Monkeys on a Polygon C++ Python O(logn) O(1) Medium Combinatorics, Fast Exponentiation
2562 Find the Array Concatenation Value C++ Python O(nlogr) O(1) Easy Math
2568 Minimum Impossible OR C++ Python O(logr) O(1) Medium Math, Hash Table, Bit Manipulations
2579 Count Total Number of Colored Cells C++ Python O(1) O(1) Medium Math
2582 Pass the Pillow C++ Python O(1) O(1) Medium Math
2584 Split the Array to Make Coprime Products C++ Python O(n * sqrt(r)) O(sqrt(r)) Hard Math, Number Theory
2614 Prime In Diagonal C++ Python precompute: O(MAX_N)
runtime: O(n)
O(MAX_N) Easy Number Theory, Linear Sieve of Eratosthenes
2651 Calculate Delayed Arrival Time C++ Python O(1) O(1) Easy Math
2652 Sum Multiples C++ Python O(1) O(1) Easy Math, Principle of Inclusion and Exclusion
2656 Maximum Sum With Exactly K Elements C++ Python O(n) O(1) Easy Math
2731 Movement of Robots C++ Python O(nlogn) O(1) Medium Sort, Math
2739 Total Distance Traveled C++ Python O(1) O(1) Easy Math
2749 Minimum Operations to Make the Integer Zero C++ Python O(1) O(1) Medium Linear Search, Bit Manipulations, Math
2750 Ways to Split Array Into Good Subarrays C++ Python O(n) O(1) Medium Combinatorics
2761 Prime Pairs With Target Sum C++ Python O(n) O(n) Medium Number Theory, Linear Sieve of Eratosthenes
2778 Sum of Squares of Special Elements C++ Python O(sqrt(n)) O(1) Easy Number Theory
2780 Minimum Index of a Valid Split C++ Python O(n) O(1) Medium Boyer–Moore Majority Vote Algorithm, Linear Search
2802 Find The K-th Lucky Number C++ Python O(logn) O(1) Medium πŸ”’ Math, Bitmasks
2806 Account Balance After Rounded Purchase C++ Python O(1) O(1) Easy Math
2833 Furthest Point From Origin C++ Python O(1) O(1) Easy Math
2862 Maximum Element-Sum of a Complete Subset of Indices C++ Python O(n) O(n) Hard Number Theory, Basel Problem
2861 Maximum Number of Alloys C++ Python O(k * nlogn) O(n) Medium Binary Search, Sort, Math
2894 Divisible and Non-divisible Sums Difference C++ Python O(1) O(1) Easy Math
2898 Maximum Linear Stock Score C++ Python O(n) O(n) Medium πŸ”’ Math, Freq Table
2927 Distribute Candies Among Children III C++ Python O(1) O(1) Hard πŸ”’ Stars and Bars, Combinatorics, Principle of Inclusion and Exclusion
2928 Distribute Candies Among Children I C++ Python O(1) O(1) Easy Stars and Bars, Combinatorics, Principle of Inclusion and Exclusion, Brute Force
2929 Distribute Candies Among Children II C++ Python O(1) O(1) Medium Stars and Bars, Combinatorics, Principle of Inclusion and Exclusion, Brute Force
2930 Number of Strings Which Can Be Rearranged to Contain Substring C++ Python O(1) O(1) Medium Combinatorics, Principle of Inclusion and Exclusion, Bitmasks, DP
2954 Count the Number of Infection Sequences C++ Python precompute: O(max_n)
runtime: O(s + logn)
O(max_n) Hard Combinatorics
2961 Double Modular Exponentiation C++ Python O(n * (logb + logc)) O(1) Medium Fast Exponentiation
2963 Count the Number of Good Partitions C++ Python O(n) O(n) Hard Hash Table, Combinatorics
2979 Most Expensive Item That Can Not Be Bought C++ Python O(1) O(1) Medium πŸ”’ Frobenius Coin Problem, Chicken McNugget Theorem, DP
2999 Count the Number of Powerful Integers C++ Python O(logf) O(1) Hard Math, Combinatorics
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


Sort

# Title Solution Time Space Difficulty Tag Note
2015 Average Height of Buildings in Each Segment C++ Python O(nlogn) O(n) Medium πŸ”’ Line Sweep
2021 Brightest Position on Street C++ Python O(nlogn) O(n) Medium πŸ”’ Line Sweep
2070 Most Beautiful Item for Each Query C++ Python O(nlogn + qlogn) O(1) Medium Sort, Binary Search
2089 Find Target Indices After Sorting Array C++ Python O(n) O(1) Easy Counting Sort
2158 Amount of New Area Painted Each Day C++ Python O(nlogr) O(r) Hard πŸ”’ Line Sweep, Sorted List, Heap, Segment Tree
2164 Sort Even and Odd Indices Independently C++ Python O(n) O(c) Easy Counting Sort, Inplace
2191 Sort the Jumbled Numbers C++ Python O(nlogm + nlogn) O(n) Medium Sort
2231 Largest Number After Digit Swaps by Parity C++ Python O(logn) O(1) Easy Counting Sort
2233 Maximum Product After K Increments C++ Python O(n + k) O(n) Medium Heap, Freq Table, Sort, Math
2248 Intersection of Multiple Arrays C++ Python O(n * l + r) O(l) Easy Hash Table, Counting Sort
2251 Number of Flowers in Full Bloom C++ Python O(nlogn + mlogn) O(n) Hard Line Sweep, Binary Search
2343 Query Kth Smallest Trimmed Number C++ Python O(q + n * t) O(t + n + q) Medium Sort, Quick Select, Radix Sort
2418 Sort the People C++ Python O(nlogn) O(n) Easy Sort
2497 Maximum Star Sum of a Graph C++ Python O(n) O(n) Medium Sort, Quick Select
2512 Reward Top K Students C++ Python O(pf * l + nf * l + n * l + klogk) O(pf * l + nf * l + n) Medium Partial Sort, Quick Select
2545 Sort the Students by Their Kth Score C++ Python O(mlogm) O(1) Medium Sort
2659 Make Array Empty C++ Python O(nlogn) O(n) Hard Sort, BIT, Fenwick Tree
2679 Sum in a Matrix C++ Python O(m * nlogn) O(1) Medium Sort
2740 Find the Value of the Partition C++ Python O(nlogn) O(1) Medium Sort
2785 Sort Vowels in a String C++ Python O(n) O(1) Medium Counting Sort
2792 Count Nodes That Are Great Enough C++ Python O(k * h) O(k + h) Hard πŸ”’ Merge Sort
2948 Make Lexicographically Smallest Array by Swapping Elements C++ Python O(nlogn) O(n) Medium Sort
2974 Minimum Number Game C++ Python O(nlogn) O(1) Easy Sort
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


Two Pointers

# Title Solution Time Space Difficulty Tag Note
2009 Minimum Number of Operations to Make Array Continuous C++ Python O(nlogn) O(1) Hard Two Pointers, Sliding Window
2024 Maximize the Confusion of an Exam C++ Python O(n) O(1) Medium variant of Longest Repeating Character Replacement Sliding Window
2040 Kth Smallest Product of Two Sorted Arrays C++ Python O((m + n) * logr) O(1) Hard Binary Search, Two Pointers
2046 Sort Linked List Already Sorted Using Absolute Values C++ Python O(n) O(1) Medium πŸ”’ Linked List
2062 Count Vowel Substrings of a String C++ Python O(n) O(1) Easy variant of Count Number of Nice Subarrays Sliding Window
2067 Number of Equal Count Substrings C++ Python O(n) O(1) Medium πŸ”’ Sliding Window
2090 K Radius Subarray Averages C++ Python O(n) O(1) Medium Sliding Window
2105 Watering Plants II C++ Python O(n) O(1) Medium Simulation
2107 Number of Unique Flavors After Sharing K Candies C++ Python O(n) O(n) Medium πŸ”’ Sliding Window
2134 Minimum Swaps to Group All 1's Together II C++ Python O(n) O(1) Medium Sliding Window
2149 Rearrange Array Elements by Sign C++ Python O(n) O(1) Medium Two Pointers
2161 Partition Array According to Given Pivot C++ Python O(n) O(n) Medium Two Pointers
2200 Find All K-Distant Indices in an Array C++ Python O(n) O(1) Easy Two Pointers
2234 Maximum Total Beauty of the Gardens C++ Python O(nlogn) O(1) Hard Sort, Prefix Sum, Greedy, Binary Search, Two Pointers
2302 Count Subarrays With Score Less Than K C++ Python O(n) O(1) Hard Two Pointers, Sliding Window
2330 Valid Palindrome IV C++ Python O(n) O(1) Medium πŸ”’ String, Two Pointers
2332 The Latest Time to Catch a Bus C++ Python O(nlogn + mlogm) O(1) Medium String, Two Pointers
2337 Move Pieces to Obtain a String C++ Python O(n + m) O(1) Medium String, Two Pointers
2348 Number of Zero-Filled Subarrays C++ Python O(n) O(1) Medium Two Pointers, Combinatorics
2379 Minimum Recolors to Get K Consecutive Black Blocks C++ Python O(n) O(1) Easy Sliding Window
2393 Count Strictly Increasing Subarrays C++ Python O(n) O(1) Medium πŸ”’ Two Pointers
2401 Longest Nice Subarray C++ Python O(n) O(1) Medium Sliding Window, Two Pointers
2444 Count Subarrays With Fixed Bounds C++ Python O(n) O(1) Hard variant of Number of Substrings Containing All Three Characters Two Pointers
2461 Maximum Sum of Distinct Subarrays With Length K C++ Python O(n) O(k) Medium Two Pointers
2465 Number of Distinct Averages C++ Python O(nlogn) O(n) Easy Two Pointers, Hash Table
2511 Maximum Enemy Forts That Can Be Captured C++ Python O(n) O(1) Easy Array, Two Pointers
2516 Take K of Each Character From Left and Right C++ Python O(n) O(1) Medium Sliding Window, Two Pointers
2524 Maximum Frequency Score of a Subarray C++ Python O(n) O(n) Hard πŸ”’ Sliding Window, Two Pointers, Freq Table, Hash Table
2537 Count the Number of Good Subarrays C++ Python O(n) O(n) Medium Sliding Window, Two Pointers
2540 Minimum Common Value C++ Python O(n) O(1) Easy Two Pointers
2555 Maximize Win From Two Segments C++ Python O(n) O(n) Medium Two Pointers, Sliding Window, DP
2563 Count the Number of Fair Pairs C++ Python O(nlogn) O(1) Medium Sort, Two Pointers
2570 Merge Two 2D Arrays by Summing Values C++ Python O(n) O(1) Easy Two Pointers
2609 Find the Longest Balanced Substring of a Binary String C++ Python O(n) O(1) Easy String, Two Pointers
2653 Sliding Subarray Beauty C++ Python O(nlogk) O(k) Medium Sorted List, Ordered Set, Two Pointers
2730 Find the Longest Semi-Repetitive Substring C++ Python O(n) O(1) Medium Two Pointers
2743 Count Substrings Without Repeating Character C++ Python O(n) O(1) Medium πŸ”’, variant of Longest Substring Without Repeating Characters Two Pointers, Sliding Window
2747 Count Zero Request Servers C++ Python O(nlogn + mlogm) O(n + m) Hard Sort, Two Pointers, Line Sweep
2762 Continuous Subarrays C++ Python O(n) O(1) Medium Mono Deque, BST, Ordered Dict, Two Pointers, Sliding Window
2763 Sum of Imbalance Numbers of All Subarrays C++ Python O(n) O(n) Hard Two Pointers, Sliding Window, Hash Table, Combinatorics
2779 Maximum Beauty of an Array After Applying Operation C++ Python O(nlogn) O(1) Medium Sort, Two Pointers, Sliding Window
2781 Length of the Longest Valid Substring C++ Python O((m + n) * l) O(t) Hard Two Pointers, Sliding Window, Trie
2799 Count Complete Subarrays in an Array C++ Python O(n) O(n) Medium Freq Table, Two Pointers, Sliding Window
2824 Count Pairs Whose Sum is Less than Target C++ Python O(nlogn) O(1) Easy Sort, Two Pointers
2831 Find the Longest Equal Subarray C++ Python O(n) O(n) Medium Freq Table, Two Pointers, Sliding Window
2838 Maximum Coins Heroes Can Collect C++ Python O(nlogn + mlogm) O(n + m) Medium πŸ”’ Sort, Two Pointers
2841 Maximum Sum of Almost Unique Subarray C++ Python O(n) O(n) Medium Freq Table, Two Pointers, Sliding Window
2875 Minimum Size Subarray in Infinite Array C++ Python O(n) O(1) Medium Prefix Sum, Hash Table, Two Pointers, Sliding Window
2904 Shortest and Lexicographically Smallest Beautiful String C++ Python O(n^2) O(1) Medium Two Pointers, Sliding Window
2933 High-Access Employees C++ Python O(nlogn) O(n) Medium Sort, Two Pointers, Sliding Window
2938 Separate Black and White Balls C++ Python O(n) O(1) Medium Two Pointers
2953 Count Complete Substrings C++ Python O(26 + d * n) O(26) Medium Freq Table, Two Pointers, Sliding Window
2958 Length of Longest Subarray With at Most K Frequency C++ Python O(n) O(n) Medium Freq Table, Two Pointers, Sliding Window
2962 Count Subarrays Where Max Element Appears at Least K Times C++ Python O(n) O(1) Medium Two Pointers, Sliding Window
2968 Apply Operations to Maximize Frequency Score C++ Python O(nlogn) O(1) Hard Sort, Two Pointers, Sliding Window, Prefix Sum, Binary Search
2970 Count the Number of Incremovable Subarrays I C++ Python O(n) O(1) Easy Two Pointers, Brute Force
2972 Count the Number of Incremovable Subarrays II C++ Python O(n) O(1) Hard Two Pointers
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


Recursion

# Title Solution Time Space Difficulty Tag Note
2613 Beautiful Pairs C++ Python O(n) on average O(n) Hard πŸ”’, variant of SPOJ - Closest Point Pair Random Algorithms, Divide and Conquer, Merge Sort, Segment Tree


Binary Search

# Title Solution Time Space Difficulty Tag Note
2064 Minimized Maximum of Products Distributed to Any Store C++ Python O(nlogm) O(1) Medium variant of Minimum Limit of Balls in a Bag
2111 Minimum Operations to Make the Array K-Increasing C++ Python O(nlog(n/k)) O(n/k) Hard variant of Longest Increasing Subsequence
2137 Pour Water Between Buckets to Make Water Levels Equal C++ Python O(nlogr) O(1) Medium πŸ”’
2187 Minimum Time to Complete Trips C++ Python O(nlogr) O(1) Medium
2226 Maximum Candies Allocated to K Children C++ Python O(nlogr) O(1) Medium Binary Search
2250 Count Number of Rectangles Containing Each Point C++ Python O(nlogn + m * max_y * logn) O(n) Medium Bucket Sort, Binary Search
2300 Successful Pairs of Spells and Potions C++ Python O(mlogm + nlogm) O(1) Medium Binary Search
2333 Minimum Sum of Squared Difference C++ Python O(nlogn + nlogr) O(1) Medium Binary Search
2387 Median of a Row Wise Sorted Matrix C++ Python O(logr * mlogn) O(1) Medium πŸ”’ Binary Search
2389 Longest Subsequence With Limited Sum C++ Python O(nlogn + qlogn) O(1) Easy Greedy, Sort, Binary Search
2448 Minimum Cost to Make Array Equal C++ Python O(nlogn) O(n) Hard Math, Binary Search, Prefix Sum
2476 Closest Nodes Queries in a Binary Search Tree C++ Python O(n + qlogn) O(n) Hard DFS, Binary Search
2513 Minimize the Maximum of Two Arrays C++ Python O(log(min(d1, d2))) O(1) Medium Number Theory, Binary Search
2517 Maximum Tastiness of Candy Basket C++ Python O(nlogr) O(1) Medium Binary Search, Greedy
2528 Maximize the Minimum Powered City C++ Python O(nlogk) O(n) Hard Binary Search, Sliding Window, Greedy
2529 Maximum Count of Positive Integer and Negative Integer C++ Python O(logn) O(1) Easy Binary Search
2554 Maximum Number of Integers to Choose From a Range I C++ Python O(b) O(b) Medium Math, Binary Search, Prefix Sum, Greedy
2557 Maximum Number of Integers to Choose From a Range II C++ Python O(b) O(b) Medium πŸ”’ Math, Binary Search, Prefix Sum
2560 House Robber IV C++ Python O(nlogn) O(n) Medium Binary Search, Greedy
2594 Minimum Time to Repair Cars C++ Python O(mx * (logc + log(mn))) O(mx) Medium Freq Table, Binary Search, Heap, Simulation
2602 Minimum Operations to Make All Array Elements Equal C++ Python O(nlogn + qlogn) O(n) Medium Sort, Binary Search, Prefix Sum
2616 Minimize the Maximum Difference of Pairs C++ Python O(nlogn + nlogr) O(1) Medium Sort, Binary Search, Greedy
2702 Minimum Operations to Make Numbers Non-positive C++ Python O(nlogr) O(1) Hard πŸ”’ Binary Search, Greedy
2936 Number of Equal Numbers Blocks C++ Python O(klogn) O(1) Medium πŸ”’ Binary Search
2940 Find Building Where Alice and Bob Can Meet C++ Python O(n + qlogn) O(n) Hard Heap, Mono Stack, Binary Search, Online Solution, Segment Tree
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


Binary Search Tree

# Title Solution Time Space Difficulty Tag Note
2426 Number of Pairs Satisfying Inequality C++ Python O(nlogn) O(n) Hard Merge Sort, Two Pointers, BIT, Fenwick Tree, Coordinate Compression, Sorted List, Ordered Set, Binary Search
2689 Extract Kth Character From The Rope Tree C++ Python O(h) O(1) Medium πŸ”’ BST
2817 Minimum Absolute Difference Between Elements With Constraint C++ Python O(nlogn) O(n) Medium Sorted List, BST, Binary Search
2907 Maximum Profitable Triplets With Increasing Prices I C++ Python O(nlogn) O(n) Medium πŸ”’ Prefix Sum, Sorted List, BST, Binary Search, Mono Stack, BIT, Fenwick Tree, Segment Tree
2921 Maximum Profitable Triplets With Increasing Prices II C++ Python O(nlogn) O(n) Hard πŸ”’ Prefix Sum, Sorted List, BST, Binary Search, Mono Stack, BIT, Fenwick Tree, Segment Tree
2926 Maximum Balanced Subsequence Sum C++ Python O(nlogn) O(n) Hard Sorted List, BST, Binary Search, Mono Stack, BIT, Fenwick Tree, Segment Tree
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


Breadth-First Search

# Title Solution Time Space Difficulty Tag Note
2039 The Time When the Network Becomes Idle C++ Python O(|E|) O(|E|) Medium Math
2045 Second Minimum Time to Reach Destination C++ Python O(|E|) O(|E|) Hard Bi-BFS
2050 Parallel Courses III C++ Python O(|V| + |E|) O(|E|) Hard variant of Parallel Courses Topological Sort
2059 Minimum Operations to Convert Number C++ Python O(m * n) O(m) Medium
2115 Find All Possible Recipes from Given Supplies C++ Python O(|E|) O(|E|) Medium Topological Sort
2146 K Highest Ranked Items Within a Price Range C++ Python O(m * n + klogk) O(m * n) Medium BFS, Quick Select, Sort
2258 Escape the Spreading Fire C++ Python O(m * n) O(m * n) Hard BFS
2290 Minimum Obstacle Removal to Reach Corner C++ Python O(m * n) O(m * n) Hard variant of Minimum Cost to Make at Least One Valid Path in a Grid A* Search Algorithm, 0-1 BFS, Deque
2316 Count Unreachable Pairs of Nodes in an Undirected Graph C++ Python O(n) O(n) Medium Flood Fill, BFS, Math
2368 Reachable Nodes With Restrictions C++ Python O(n) O(n) Medium BFS
2415 Reverse Odd Levels of Binary Tree C++ Python O(n) O(n) Medium BFS
2471 Minimum Number of Operations to Sort a Binary Tree by Level C++ Python O(nlogn) O(w) Medium Sort, BFS
2492 Minimum Score of a Path Between Two Cities C++ Python O(n + m) O(n + m) Medium BFS
2493 Divide Nodes Into the Maximum Number of Groups C++ Python O(n^2) O(n) Medium variant of Is Graph Bipartite? BFS, DFS
2503 Maximum Number of Points From Grid Queries C++ Python O((m * n + q) * log(m * n)) O(m * n) Hard BFS, Heap, Prefix Sum, Binary Search
2577 Minimum Time to Visit a Cell In a Grid C++ Python O(m * n * log(m * n)) O(m * n) Hard Dijkstra's Algorithm
2583 Kth Largest Sum in a Binary Tree C++ Python O(n) O(n) Medium BFS, Quick Select
2603 Collect Coins in a Tree C++ Python O(n) O(n) Hard Tree, BFS
2612 Minimum Reverse Operations C++ Python O(n) O(n) Hard BFS, Union Find, BST, Sorted List
2617 Minimum Number of Visited Cells in a Grid C++ Python O(m * n) O(m * n) Hard variant of Minimum Reverse Operations BFS, Union Find, BST, Sorted List
2641 Cousins in Binary Tree II C++ Python O(n) O(w) Medium BFS
2658 Maximum Number of Fish in a Grid C++ Python O(m * n) O(m + n) Medium BFS, DFS
2685 Count the Number of Complete Components C++ Python O(n) O(n) Medium BFS
2709 Greatest Common Divisor Traversal C++ Python precompute: O(sqrt(r))
runtime: O(n * (logr + sqrt(r)/log(sqrt(r))))
O(sqrt(r) + nlogr) Hard Linear Sieve of Eratosthenes, Factorization, BFS
2812 Find the Safest Path in a Grid C++ Python O(n^2) O(n^2) Medium BFS, Bucket Sort, Union Find, Dijkstra's Algorithm, Binary Search
2814 Minimum Time Takes to Reach Destination Without Drowning C++ Python O(m * n) O(m * n) Hard πŸ”’ Simulation, BFS
2852 Sum of Remoteness of All Cells C++ Python O(n^2) O(n^2) Medium πŸ”’ Flood Fill, BFS, Math
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


Depth-First Search

# Title Solution Time Space Difficulty Tag Note
2049 Count Nodes With the Highest Score C++ Python O(n) O(n) Medium
2065 Maximum Path Quality of a Graph C++ Python O(|V| + |E| + 4^10) O(|V| + |E| ) Hard Pruning
2192 All Ancestors of a Node in a Directed Acyclic Graph C++ Python O(|V| * |E|) O(|V| + |E|) Medium DFS, BFS, Topological Sort
2246 Longest Path With Different Adjacent Characters C++ Python O(n) O(h) Hard DFS, BFS, Topological Sort
2265 Count Nodes Equal to Average of Subtree C++ Python O(n) O(h) Medium DFS, Tree
2322 Minimum Score After Removals on a Tree C++ Python O(n^2) O(n) Hard DFS, Tree
2331 Evaluate Boolean Binary Tree C++ Python O(n) O(h) Easy DFS
2385 Amount of Time for Binary Tree to Be Infected C++ Python O(n) O(h) Medium BFS, DFS, Tree DP
2445 Number of Nodes With Value One C++ Python O(q + h) O(q + h) Medium πŸ”’ Tree, DFS, BFS
2458 Height of Binary Tree After Subtree Removal Queries C++ Python O(n) O(n) Hard Tree, DFS
2467 Most Profitable Path in a Tree C++ Python O(n) O(n) Medium Tree, DFS
2477 Minimum Fuel Cost to Report to the Capital C++ Python O(n) O(h) Medium Tree, DFS
2581 Count Number of Possible Root Nodes C++ Python O(n) O(h) Hard Tree, DFS
2773 Height of Special Binary Tree C++ Python O(n) O(h) Medium πŸ”’ Tree, DFS, BFS
2791 Count Paths That Can Form a Palindrome in a Tree C++ Python O(n) O(n) Hard Tree, DFS, Freq Table
2973 Find Number of Coins to Place in Tree Nodes C++ Python O(n) O(n) Hard DFS
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


Backtracking

# Title Solution Time Space Difficulty Tag Note
2014 Longest Subsequence Repeated k Times C++ Python O(n * (n/k)!) O(n/k) Hard
2056 Number of Valid Move Combinations On Chessboard C++ Python O(1) O(1) Hard
2094 Finding 3-Digit Even Numbers C++ Python O(n) O(1) Easy
2443 Sum of Number and Its Reverse C++ Python O(n^(1/(2*log2(10)))) O(log10(n)/2) Medium Brute Force, Backtracking
2664 The Knight’s Tour C++ Python O(m * n) O(1) Medium πŸ”’ Backtracking, Greedy, Warnsdorff's Rule
2698 Find the Punishment Number of an Integer C++ Python O(n * (logn)^(2*logn)) O(logn) Medium Backtracking
2741 Special Permutations C++ Python O(n^2 * 2^n) O(n * 2^n) Medium Backtracking, Memoization
3211 Generate Binary Strings Without Adjacent Zeros C++ Python O(n * 2^n) O(n) Medium Backtracking, BFS


Dynamic Programming

# Title Solution Time Space Difficulty Tag Note
2002 Maximum Product of the Length of Two Palindromic Subsequences C++ Python O(3^n) O(2^n) Medium DP, Submask Enumeration
2008 Maximum Earnings From Taxi C++ Python O(n + mlogm) O(n) Medium DP
2019 The Score of Students Solving Math Expression C++ Python O(n^3 * a^2) O(n^2) Hard variant of Burst Balloons
2031 Count Subarrays With More Ones Than Zeros C++ Python O(n) O(n) Medium πŸ”’ Prefix Sum, DP
2044 Count Number of Maximum Bitwise-OR Subsets C++ Python O(min(2^n, m * n)) O(min(2^n, m)) Medium DP
2052 Minimum Cost to Separate Sentence Into Rows C++ Python O(s + n * k) O(k) Medium πŸ”’ DP
2060 Check if an Original String Exists Given Two Encoded Strings C++ Python O(m * n * k) O(min(m, n) * k) Hard DP, Memoization
2088 Count Fertile Pyramids in a Land C++ Python O(m * n) O(n) Hard DP
2140 Solving Questions With Brainpower C++ Python O(n) O(n) Medium DP
2143 Choose Numbers From Two Arrays in Range C++ Python O(n^2 * v) O(n * v) Hard πŸ”’ DP
2167 Minimum Time to Remove All Cars Containing Illegal Goods C++ Python O(n) O(1) Hard DP
2174 Remove All Ones With Row and Column Flips II C++ Python O((m * n) * 2^(m * n)) O(2^(m * n)) Medium πŸ”’ DP, Bitmasks
2184 Number of Ways to Build Sturdy Brick Wall C++ Python O(h * p^2) O(p^2) Medium πŸ”’, variant of Painting a Grid With Three Different Colors DP, Backtracking, Matrix Exponentiation
2188 Minimum Time to Finish the Race C++ Python O((n + l) * logc) O(n + l + logc) Hard Greedy, DP
2189 Number of Ways to Build House of Cards C++ Python O(n^2) O(n) Medium πŸ”’ DP
2209 Minimum White Tiles After Covering With Carpets C++ Python O(m * n) O(m * n) Hard DP
2218 Maximum Value of K Coins From Piles C++ Python O(min(n * k^2, m * k))) O(k) Hard DP
2222 Number of Ways to Select Buildings C++ Python O(n) O(1) Medium DP
2247 Maximum Cost of Trip With K Highways C++ Python O(n^2 * 2^n) O(n * 2^n) Hard πŸ”’ DP, Bitmasks, BFS
2266 Count Number of Texts C++ Python O(n) O(1) Medium DP
2267 Check if There Is a Valid Parentheses String Path C++ Python O(m * n * (m + n) / 32) O(n * (m + n) / 32) Hard variant of Codeforces Round #801 C DP, Bitsets
2289 Steps to Make Array Non-decreasing C++ Python O(n) O(n) Hard DP, Mono Stack
2291 Maximum Profit From Trading Stocks C++ Python O(n * b) O(b) Medium πŸ”’ DP
2297 Jump Game IX C++ Python O(n) O(1) Medium πŸ”’ DP, Mono Stack
2304 Minimum Path Cost in a Grid C++ Python O(m * n^2) O(n) Medium DP
2305 Fair Distribution of Cookies C++ Python O(k * 3^n) O(2^n) Medium DP, Submask Enumeration
2312 Selling Pieces of Wood C++ Python O(m * n * (m + n)) O(m + n) Hard DP
2313 Minimum Flips in Binary Tree to Get Result C++ Python O(n) O(h) Hard πŸ”’ Tree DP
2318 Number of Distinct Roll Sequences C++ Python O(6^3 * n) O(6^2) Hard DP
2320 Count Number of Ways to Place Houses C++ Python O(logn) O(1) Medium variant of Fibonacci Number Matrix Exponentiation
2327 Number of People Aware of a Secret C++ Python O(n) O(f) Medium DP
2328 Number of Increasing Paths in a Grid C++ Python O(m * n) O(m * n) Hard Memoization, Topological Sort, DP
2361 Minimum Costs Using the Train Line C++ Python O(n) O(1) Hard πŸ”’ DP
2369 Check if There is a Valid Partition For The Array C++ Python O(n) O(1) Medium DP
2370 Longest Ideal Subsequence C++ Python O(n) O(1) Medium DP
2378 Choose Edges to Maximize Score in a Tree C++ Python O(n) O(n) Medium πŸ”’ DFS, Stack, Tree DP
2380 Time Needed to Rearrange a Binary String C++ Python O(n) O(1) Medium DP
2403 Minimum Time to Kill All Monsters C++ Python O(n * 2^n) O(2^n) Hard πŸ”’ Bitmasks, DP
2420 Find All Good Indices C++ Python O(n) O(n) Medium Prefix Sum
2430 Maximum Deletions on a String C++ Python O(n^2) O(n) Hard DP, Rabin-Karp Algorithm, Rolling Hash, Longest Prefix Suffix, KMP Algorithm
2431 Maximize Total Tastiness of Purchased Fruits C++ Python O(n * a * c) O(a * c) Medium πŸ”’ DP
2435 Paths in Matrix Whose Sum Is Divisible by K C++ Python O(m * n * k) O(n * k) Hard DP
2447 Number of Subarrays With GCD Equal to K C++ Python O(nlogr) O(logr) Medium DP
2463 Minimum Total Distance Traveled C++ Python O(mlogm + nlogn + m * n) O(n) Hard Sort, DP, Prefix Sum, Mono Deque
2464 Minimum Subarrays in a Valid Split C++ Python O(n^2 * logr) O(n) Medium πŸ”’ DP
2466 Count Ways To Build Good Strings C++ Python O(n) O(n) Medium DP
2470 Number of Subarrays With LCM Equal to K C++ Python O(n * sqrt(k) * logk) O(sqrt(k)) Medium variant of Number of Subarrays With GCD Equal to K DP
2470 Number of Subarrays With LCM Equal to K C++ Python O(n * sqrt(k) * logk) O(sqrt(k)) Medium variant of Number of Subarrays With GCD Equal to K DP
2475 Number of Unequal Triplets in Array C++ Python O(n) O(n) Easy DP, Freq Table, Math
2478 Number of Beautiful Partitions C++ Python O(n * k) O(n) Hard DP
2495 Number of Subarrays Having Even Product C++ Python O(n) O(1) Medium πŸ”’ DP, Math
2510 Check if There is a Path With Equal Number of 0's And 1's C++ Python O(m * n) O(n) Medium πŸ”’ DP
2518 Number of Great Partitions C++ Python O(n * k) O(k) Hard Knapsack DP
2533 Number of Good Binary Strings C++ Python O(n) O(w) Medium πŸ”’ DP
2538 Difference Between Maximum and Minimum Price Sum C++ Python O(n) O(n) Hard DFS, Tree DP
2547 Minimum Cost to Split an Array C++ Python O(n^2) O(n) Hard DP
2552 Count Increasing Quadruplets C++ Python O(n^2) O(n) Hard variant of 132 Pattern DP, Prefix Sum
2556 Disconnect Path in a Binary Matrix by at Most One Flip C++ Python O(m * n) O(m + n) Medium DP, DFS
2565 Subsequence With the Minimum Score C++ Python O(n) O(n) Hard Two Pointers, DP
2572 Count the Number of Square-Free Subsets C++ Python O(n + m * 2^p) O(m * 2^p) Medium Number Theory, Combinatorics, Bitmasks, Memoization, DP
2585 Number of Ways to Earn Points C++ Python O(n * t * c) O(t) Hard Knapsack DP
2597 The Number of Beautiful Subsets C++ Python O(n) O(n) Medium Combinatorics, DP
2638 Count the Number of K-Free Subsets C++ Python O(n) O(n) Medium πŸ”’, variant of The Number of Beautiful Subsets Combinatorics, DP
2646 Minimize the Total Price of the Trips C++ Python O(t * n) O(n) Hard DFS, Tree DP
2681 Power of Heroes C++ Python O(nlogn) O(1) Hard Sort, Combinatorics, DP
2684 Maximum Number of Moves in a Grid C++ Python O(m * n) O(m) Medium DP, BFS
2707 Extra Characters in a String C++ Python O(n * l) O(n + t) Medium DP, Trie
2713 Maximum Strictly Increasing Cells in a Matrix C++ Python O(m * n * log(m * n)) O(m * n) Hard Sort, DP
2719 Count of Integers C++ Python O(m * n) O(m + n) Hard Combinatorics, DP
2742 Painting the Walls C++ Python O(n^2) O(n) Hard Knapsack DP
2746 Decremental String Concatenation C++ Python O(n) O(1) Medium DP
2767 Partition String Into Minimum Beautiful Substrings C++ Python O(n^2) O(n) Medium DP
2770 Maximum Number of Jumps to Reach the Last Index C++ Python O(n^2) O(n) Medium DP
2771 Longest Non-decreasing Subarray From Two Arrays C++ Python O(n) O(1) Medium DP
2786 Visit Array Positions to Maximize Score C++ Python O(n) O(1) Medium DP
2787 Ways to Express an Integer as Sum of Powers C++ Python O(nlogn) O(n) Medium Knapsack DP
2801 Count Stepping Numbers in Range C++ Python O(n) O(1) Hard DP
2809 Minimum Time to Make Array Sum At Most x C++ Python O(n^2) O(n) Hard Sort, Greedy, DP, Linear Search
2826 Sorting Three Groups C++ Python O(n) O(1) Medium DP
2827 Number of Beautiful Integers in the Range C++ Python O(n^2 * k) O(n * k) Hard DP, Memoization
2830 Maximize the Profit as the Salesman C++ Python O(n + m) O(n + m) Medium DP
2858 Minimum Edge Reversals So Every Node Is Reachable C++ Python O(n) O(n) Hard DFS, Tree DP
2867 Count Valid Paths in a Tree C++ Python O(n) O(n) Hard Number Theory, Linear Sieve of Eratosthenes, DFS, Tree DP, Union Find
2896 Apply Operations to Make Two Strings Equal C++ Python O(n) O(1) Medium DP
2901 Longest Unequal Adjacent Groups Subsequence II C++ Python O(n^2) O(n) Medium DP, Backtracing, LIS DP
2902 Count of Sub-Multisets With Bounded Sum C++ Python O(n + d * r) O(d + r) Hard Freq Table, DP, Sliding Window, Combinatorics
2911 Minimum Changes to Make K Semi-palindromes C++ Python O(n^3) O(n^2 * logn) Hard Number Theory, DP
2912 Number of Ways to Reach Destination in the Grid C++ Python O(logn) O(1) Hard πŸ”’ DP, Matrix Exponentiation
2913 Subarrays Distinct Element Sum of Squares I C++ Python O(nlogn) O(n) Easy DP, Segment Tree, BIT, Fenwick Tree, Ordered Set, Sorted List, Math, Hash Table
2915 Length of the Longest Subsequence That Sums to Target C++ Python O(n * t) O(t) Medium Knapsack DP
2916 Subarrays Distinct Element Sum of Squares II C++ Python O(nlogn) O(n) Easy DP, Segment Tree, BIT, Fenwick Tree, Ordered Set, Sorted List, Math
2919 Minimum Increment Operations to Make Array Beautiful C++ Python O(n) O(1) Medium DP
2920 Maximum Points After Collecting Coins From All Nodes C++ Python O(nlogr) O(n) Hard Tree DP, Memoization, DFS, Pruning
2925 Maximum Score After Applying Operations on a Tree C++ Python O(n) O(n) Medium DFS, Tree DP
2941 Maximum GCD-Sum of a Subarray C++ Python O(nlogr) O(logr) Hard πŸ”’ Number Theory, DP, Prefix Sum, Binary Search, RMQ, Sparse Table
2944 Minimum Number of Coins for Fruits C++ Python O(n) O(n) Medium DP, Sorted List, BST, Mono Deque
2945 Find Maximum Non-decreasing Array Length C++ Python O(n) O(n) Hard DP, Greedy, Prefix Sum, Binary Search, Mono Stack, Mono Deque, Two Pointers
2969 Minimum Number of Coins for Fruits II C++ Python O(n) O(n) Hard πŸ”’ DP, Sorted List, BST, Mono Deque
2976 Minimum Cost to Convert String I C++ Python O(o + k * eloge + n) O(o + k * v) Medium Dijkstra's Algorithm, Floyd-Warshall Algorithm, DP, Memoization
2977 Minimum Cost to Convert String II C++ Python O(o * l + k * eloge + n * l) O(t + k * v + l) Hard Dijkstra's Algorithm, Floyd-Warshall Algorithm, DP, Memoization, Trie
2992 Number of Self-Divisible Permutations C++ Python O(n * 2^n) O(2^n) Medium πŸ”’ Bitmasks, DP
2998 Minimum Number of Operations to Make X and Y Equal C++ Python O(x) O(x) Medium Memoization, BFS
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
3376 Minimum Time to Break Locks I C++ Python O(n * 2^n) O(2^n) Medium Bitmasks, DP
3381 Maximum Subarray Sum With Length Divisible by K C++ Python O(n) O(k) Medium Prefix Sum, DP


Greedy

# Title Solution Time Space Difficulty Tag Note
2027 Minimum Moves to Convert String C++ Python O(n) O(1) Easy
2030 Smallest K-Length Subsequence With Occurrences of a Letter C++ Python O(n) O(n) Hard Mono Stack, Greedy
2036 Maximum Alternating Subarray Sum C++ Python O(n) O(1) Medium variant of Maximum Alternating Subsequence Sum, πŸ”’ Greedy, Kadane's Algorithm
2037 Minimum Number of Moves to Seat Everyone C++ Python O(nlogn) O(1) Easy Greedy
2071 Maximum Number of Tasks You Can Assign C++ Python O(n * (logn)^2) O(n) Hard Greedy, Binary Search, Sorted List
2086 Minimum Number of Buckets Required to Collect Rainwater from Houses C++ Python O(n) O(1) Medium Greedy
2087 Minimum Cost Homecoming of a Robot in a Grid C++ Python O(m + n) O(1) Medium Greedy
2126 Destroying Asteroids C++ Python O(nlogn) O(1) Medium Greedy
2136 Earliest Possible Day of Full Bloom C++ Python O(nlogn) O(n) Hard Greedy
2139 Minimum Moves to Reach Target Score C++ Python O(logn) O(1) Medium
2141 Maximum Running Time of N Computers C++ Python O(nlogm) O(1) Hard Greedy, Binary Search
2144 Minimum Cost of Buying Candies With Discount C++ Python O(nlogn) O(1) Easy Greedy, Sort
2147 Number of Ways to Divide a Long Corridor C++ Python O(n) O(1) Hard Greedy, Combinatorics
2160 Minimum Sum of Four Digit Number After Splitting Digits C++ Python O(1) O(1) Easy Greedy
2165 Smallest Value of the Rearranged Number C++ Python O(d) O(d) Medium Greedy, Counting Sort
2178 Maximum Split of Positive Even Integers C++ Python O(sqrt(n)) O(1) Medium Greedy
2182 Construct String With Repeat Limit C++ Python O(n) O(1) Medium Greedy
2193 Minimum Number of Moves to Make Palindrome C++ Python O(nlogn) O(n) Hard Greedy, BIT, Fenwick Tree
2195 Append K Integers With Minimal Sum C++ Python O(nlogn) O(n) Medium Greedy
2207 Maximize Number of Subsequences in a String C++ Python O(n) O(1) Medium Counting, Greedy
2214 Minimum Health to Beat Game C++ Python O(n) O(1) Medium πŸ”’ Greedy
2216 Minimum Deletions to Make Array Beautiful C++ Python O(n) O(1) Medium Greedy
2224 Minimum Number of Operations to Convert Time C++ Python O(1) O(1) Easy Greedy
2259 Remove Digit From Number to Maximize Result C++ Python O(n) O(1) Easy Greedy
2263 Make Array Non-decreasing or Non-increasing C++ Python O(nlogn) O(n) Hard πŸ”’ DP, Greedy, Heap
2268 Minimum Number of Keypresses C++ Python O(n) O(1) Medium πŸ”’ Greedy, Sort
2279 Maximum Bags With Full Capacity of Rocks C++ Python O(nlogn) O(1) Medium Greedy, Sort
2285 Maximum Total Importance of Roads C++ Python O(n) O(n) Medium Greedy, Counting Sort
2294 Partition Array Such That Maximum Difference Is K C++ Python O(nlogn) O(1) Medium Greedy
2311 Longest Binary Subsequence Less Than or Equal to K C++ Python O(n) O(1) Medium Greedy
2321 Maximum Score Of Spliced Array C++ Python O(n) O(1) Hard Greedy, Kadane's Algorithm
2323 Find Minimum Time to Finish All Jobs II C++ Python O(nlogn) O(1) Medium πŸ”’ Greedy
2340 Minimum Adjacent Swaps to Make a Valid Array C++ Python O(n) O(1) Medium πŸ”’ Array, Greedy
2366 Minimum Replacements to Sort the Array C++ Python O(n) O(1) Hard Greedy, Math
2371 Minimize Maximum Value in a Grid C++ Python O((m * n) * log(m * n)) O(m * n) Hard πŸ”’ Sort, Greedy
2375 Construct Smallest Number From DI String C++ Python O(n) O(1) Medium Constructive Algorithms, Greedy
2383 Minimum Hours of Training to Win a Competition C++ Python O(n) O(1) Easy Greedy
2384 Largest Palindromic Number C++ Python O(n) O(1) Medium Freq Table, Greedy
2405 Optimal Partition of String C++ Python O(n) O(n) Medium Greedy, Hash Table
2410 Maximum Matching of Players With Trainers C++ Python O(nlogn + mlogm) O(1) Medium Greedy, Sort
2412 Minimum Money Required Before Transactions C++ Python O(n) O(1) Hard Greedy, Constructive Algorithms
2417 Closest Fair Integer C++ Python O(logn) O(logn) Medium πŸ”’ Constructive Algorithms, Greedy
2422 Merge Operations to Turn Array Into a Palindrome C++ Python O(n) O(1) Medium πŸ”’ Constructive Algorithms, Greedy, Two Pointers
2434 Using a Robot to Print the Lexicographically Smallest String C++ Python O(n) O(n) Medium Freq Table, Greedy
2436 Minimum Split Into Subarrays With GCD Greater Than One C++ Python O(nlogr) O(1) Medium πŸ”’ Greedy
2439 Minimize Maximum of Array C++ Python O(n) O(1) Medium Greedy
2440 Create Components With Same Value C++ Python O(n * sqrt(n)) O(n) Hard BFS, DFS, Greedy
2449 Minimum Number of Operations to Make Arrays Similar C++ Python O(nlogn) O(1) Hard Greedy, Sort
2457 Minimum Addition to Make Integer Beautiful C++ Python O(logn) O(1) Medium Greedy
2459 Sort Array by Moving Items to Empty Space C++ Python O(n) O(n) Hard πŸ”’ Greedy, Sort
2472 Maximum Number of Non-overlapping Palindrome Substrings C++ Python O(n * k) O(1) Hard Two Pointers, Greedy
2479 Maximum XOR of Two Non-Overlapping Subtrees C++ Python O(nlogr) O(n) Hard πŸ”’, variant of Maximum XOR of Two Numbers in an Array DFS, Trie, Greedy
2483 Minimum Penalty for a Shop C++ Python O(n) O(1) Medium Greedy
2486 Append Characters to String to Make Subsequence C++ Python O(n) O(1) Medium Two Pointers, Greedy
2498 Frog Jump II C++ Python O(n) O(1) Medium Greedy
2499 Minimum Total Cost to Make Arrays Unequal C++ Python O(n) O(n) Hard Greedy
2522 Partition String Into Substrings With Values at Most K C++ Python O(n) O(1) Medium Greedy
2541 Minimum Operations to Make Array Equal II C++ Python O(n) O(1) Medium Greedy
2542 Maximum Subsequence Score C++ Python O(nlogn) O(n) Medium variant of Maximum Performance of a Team Greedy, Heap
2548 Maximum Price to Fill a Bag C++ Python O(nlogn) O(1) Medium πŸ”’ Greedy, Sort
2551 Put Marbles in Bags C++ Python O(n) on average O(1) Hard Greedy, Quick Select
2561 Rearranging Fruits C++ Python O(n) on average O(n) Hard Freq Table, Greedy, Quick Select
2566 Maximum Difference by Remapping a Digit C++ Python O(logn) O(1) Easy Greedy
2567 Minimum Score by Changing Two Elements C++ Python O(nlogn) O(1) Medium Sort, Greedy
2571 Minimum Operations to Reduce an Integer to 0 C++ Python O(logn) O(1) Medium Greedy, Trick
2573 Find the String with LCP C++ Python O(n^2) O(1) Hard Constructive Algorithms, Greedy, DP
2576 Find the Maximum Number of Marked Indices C++ Python O(nlogn) O(1) Medium Sort, Greedy, Two Pointers
2578 Split With Minimum Sum C++ Python O(mlogm) O(m) Easy Sort, Greedy
2587 Rearrange Array to Maximize Prefix Score C++ Python O(nlogn) O(1) Medium Sort, Greedy
2589 Minimum Time to Complete All Tasks C++ Python O(nlogn + n * r) O(r) Hard Sort, Greedy
2591 Distribute Money to Maximum Children C++ Python O(1) O(1) Easy Greedy, Math
2599 Make the Prefix Sum Non-negative C++ Python O(nlogn) O(n) Medium πŸ”’ Prefix Sum, Greedy, Heap
2600 K Items With the Maximum Sum C++ Python O(1) O(1) Easy Greedy, Math
2601 Prime Subtraction Operation C++ Python O(p + nlogp) O(p) Medium Number Theory, Greedy, Binary Search
2604 Minimum Time to Eat All Grains C++ Python O(mlogm + nlogn + (m + n) * logr) O(1) Hard πŸ”’ Binary Search, Greedy
2606 Find the Substring With Maximum Cost C++ Python O(n) O(1) Medium Greedy, Kadane's Algorithm
2607 Make K-Subarray Sums Equal C++ Python O(n) O(n) Medium Math, Greedy, Quick Select
2611 Mice and Cheese C++ Python O(n) O(1) Medium Greedy, Quick Select
2645 Minimum Additions to Make Valid String C++ Python O(n) O(1) Medium Greedy
2663 Lexicographically Smallest Beautiful String C++ Python O(n) O(1) Hard Greedy
2673 Make Costs of Paths Equal in a Binary Tree C++ Python O(n) O(1) Medium Tree, Greedy
2680 Maximum OR C++ Python O(n) O(n) Medium Prefix Sum, Greedy
2697 Lexicographically Smallest Palindrome C++ Python O(n) O(1) Easy Greedy
2706 Buy Two Chocolates C++ Python O(n) O(1) Easy Greedy
2708 Maximum Strength of a Group C++ Python O(n) O(1) Medium Greedy
2712 Minimum Cost to Make All Characters Equal C++ Python O(n) O(1) Medium Greedy
2734 Lexicographically Smallest String After Substring Operation C++ Python O(n) O(1) Medium Greedy
2769 Find the Maximum Achievable Number C++ Python O(1) O(1) Easy Greedy, Math
2772 Apply Operations to Make All Array Elements Equal to Zero C++ Python O(n) O(1) Medium Greedy, Sliding Window
2789 Largest Element in an Array after Merge Operations C++ Python O(n) O(1) Medium Greedy
2790 Maximum Number of Groups With Increasing Length C++ Python O(n) O(n) Hard Constructive Algorithms, Counting Sort, Greedy, Binary Search, Prefix Sum
2813 Maximum Elegance of a K-Length Subsequence C++ Python O(nlogk) O(k) Hard Partial Sort, Heap, Quick Select, BST, Sorted List, Greedy
2819 Minimum Relative Loss After Buying Chocolates C++ Python O((n + q) * logn) O(n) Hard πŸ”’ Sort, Binary Search, Greedy, Prefix Sum
2825 Make String a Subsequence Using Cyclic Increments C++ Python O(n) O(1) Medium Greedy, Two Pointers
2835 Minimum Operations to Form Subsequence With Target Sum C++ Python O(n) O(logn) Hard Educational Codeforces Round #82 D Counting Sort, Sort, Heap, Greedy, Bitmasks
2842 Count K-Subsequences of a String With Maximum Beauty C++ Python O(n) O(1) Hard Greedy, Quick Select, Combinatorics
2844 Minimum Operations to Make a Special Number C++ Python O(n) O(1) Medium Math, Greedy
2847 Smallest Number With Given Digit Product C++ Python O(logn) O(logn) Medium πŸ”’ Greedy
2860 Happy Students C++ Python O(n) O(n) Medium Codeforces Round #844 B Sort, Greedy, Freq Table
2864 Maximum Odd Binary Number C++ Python O(n) O(1) Easy Greedy, Partition
2868 The Wording Game C++ Python O(m + n) O(1) Hard πŸ”’ Game, Greedy
2870 Minimum Number of Operations to Make Array Empty C++ Python O(n) O(n) Medium Freq Table, Greedy
2871 Split Array Into Maximum Number of Subarrays C++ Python O(n) O(1) Medium Greedy
2872 Maximum Number of K-Divisible Components C++ Python O(n) O(n) Hard variant of Create Components With Same Value BFS, Greedy
2892 Minimizing Array After Replacing Pairs With Their Product C++ Python O(n) O(1) Medium πŸ”’ Greedy
2895 Minimum Processing Time C++ Python O(nlogn) O(1) Medium Sort, Greedy
2897 Apply Operations on Array to Maximize Sum of Squares C++ Python O(nlogr) O(logr) Hard Bit Manipulation, Greedy, Freq Table
2900 Longest Unequal Adjacent Groups Subsequence I C++ Python O(n) O(1) Medium Greedy
2910 Minimum Number of Groups to Create a Valid Assignment C++ Python O(n) O(n) Medium Linear Search, Greedy, Math
2914 Minimum Number of Changes to Make Binary String Beautiful C++ Python O(n) O(1) Medium Greedy
2918 Minimum Equal Sum of Two Arrays After Replacing Zeros C++ Python O(n + m) O(1) Medium Greedy
2931 Minimum Equal Sum of Two Arrays After Replacing Zeros C++ Python O(m * n * logm) O(m) Hard Greedy, Heap
2939 Maximum Xor Product C++ Python O(n) O(1) Medium Greedy
2952 Minimum Number of Coins to be Added C++ Python O(nlogn + logt) O(1) Medium variant of Patching Array Sort, Greedy
2957 Remove Adjacent Almost-Equal Characters C++ Python O(n) O(1) Medium Greedy
2971 Find Polygon With the Largest Perimeter C++ Python O(n) O(1) Medium Sort, Prefix Sum, Greedy
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


Graph

# Title Solution Time Space Difficulty Tag Note
2076 Process Restricted Friend Requests C++ Python O(n * r) O(n) Hard Union Find
2077 Paths in Maze That Lead to Same Room C++ Python O(|V|^3) O(|E|) Medium πŸ”’
2092 Find All People With Secret C++ Python O(nlogn) O(nlogn) Hard BFS, DFS, Union Find
2093 Minimum Path Cost in a Hidden Grid C++ Python O(|E| * log|V|) O(|V| + |E|) Medium variant of Cheapest Flights Within K Stops, πŸ”’ Dijkstra's Algorithm, DP
2097 Valid Arrangement of Pairs C++ Python O(|V| + |E|) O(|V| + |E|) Hard variant of Reconstruct Itinerary Hierholzer's Algorithm, Eulerian Path
2123 Minimum Operations to Remove Adjacent Ones in Matrix C++ Python O(m * n * sqrt(m * n)) O(m + n) Hard variant of Maximum Students Taking Exam, πŸ”’ Hopcroft-Karp Bipartite Matching, Maximum Independent Set
2127 Maximum Employees to Be Invited to a Meeting C++ Python O(n) O(n) Hard
2172 Maximum AND Sum of Array C++ Python O(n^3) O(n^2) Hard variant of Maximum Compatibility Score Sum DP, Hungarian Weighted Bipartite Matching
2203 Minimum Weighted Subgraph With the Required Paths C++ Python O(|E| * log|V|) O(|E|) Hard Dijkstra's Algorithm
2204 Distance to a Cycle in Undirected Graph C++ Python O(|V| + |E|) O(|V| + |E|) Hard πŸ”’ Graph, DFS, BFS
2242 Maximum Score of a Node Sequence C++ Python O(|V| + |E|) O(|V|) Hard Graph
2307 Check for Contradictions in Equations C++ Python O(e + q) O(n) Hard πŸ”’, variant of Evaluate Division DFS, Union Find
2359 Find Closest Node to Given Two Nodes C++ Python O(n) O(n) Medium Graph, Hash Table, DFS
2360 Longest Cycle in a Graph C++ Python O(n) O(n) Hard Graph, Hash Table, DFS
2392 Build a Matrix With Conditions C++ Python O(k^2 + r + c) O(k + r + c) Hard Graph, Topological Sort
2473 Minimum Cost to Buy Apples C++ Python O(n * rlogn) O(n) Medium πŸ”’ Dijkstra's Algorithm
2508 Add Edges to Make Degrees of All Nodes Even C++ Python O(n) O(n) Hard Graph
2608 Shortest Cycle in a Graph C++ Python O(n^2) O(n + e) Hard Graph, BFS
2662 Minimum Cost of a Path With Special Roads C++ Python O(n^2) O(n^2) Medium Graph, Dijkstra's Algorithm
2699 Modify Graph Edge Weights C++ Python O(|E| * log|V|) O(|E|) Hard Graph, Dijkstra's Algorithm
2714 Find Shortest Path with K Hops C++ Python O(n * k + (k * e) * log(n * k)) O(n * k + e) Hard πŸ”’ Graph, Dijkstra's Algorithm
2737 Find the Closest Marked Node C++ Python O(|E| * log|V|) O(|E|) Medium πŸ”’ Graph, Dijkstra's Algorithm
2836 Maximize Value of Function in a Ball Passing Game C++ Python O(n) O(n) Hard Graph, Prefix Sum, Two Pointers, Sliding Window, Binary Lifting
2850 Minimum Moves to Spread Stones Over Grid C++ Python O(n^3) O(n^2) Medium Backtracking, Hungarian Weighted Bipartite Matching
2876 Count Visited Nodes in a Directed Graph C++ Python O(n) O(n) Hard Graph, Hash Table, Stack
2924 Find Champion II C++ Python O(n) O(n) Medium Graph, Hash Table
2959 Number of Possible Sets of Closing Branches C++ Python O(r + 2^n * n^2) O(n^3) Medium Graph, Bitmasks, Floyd-Warshall Algorithm, Backtracking
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


Geometry

# Title Solution Time Space Difficulty Tag Note
2101 Detonate the Maximum Bombs C++ Python O(|V|^2 + \V| * |E|) O(\V| + |E|) Medium Graph, DFS, BFS


Simulation

# Title Solution Time Space Difficulty Tag Note
2061 Number of Spaces Cleaning Robot Cleaned C++ Python O(m * n) O(1) Medium πŸ”’
2162 Minimum Cost to Set Cooking Time C++ Python O(1) O(1) Medium
2257 Count Unguarded Cells in the Grid C++ Python O(m * n) O(m * n) Medium Array, Simulation
2303 Calculate Amount Paid in Taxes C++ Python O(n) O(1) Easy Simulation
2507 Smallest Value After Replacing With Sum of Prime Factors C++ Python O(s * logn) O(max_n^0.5) Medium Number Theory, Simulation
2532 Time to Cross a Bridge C++ Python O(k + nlogk) O(k) Hard Heap, Simulation
2534 Time Taken to Cross the Door C++ Python O(n) O(n) Hard πŸ”’ Queue, Simulation
2593 Find Score of an Array After Marking All Elements C++ Python O(nlogn) O(n) Medium Simulation, Sort, Hash Table
2596 Check Knight Tour Configuration C++ Python O(m * n) O(m * n) Medium Simulation, Hash Table
2682 Find the Losers of the Circular Game C++ Python O(n) O(n) Easy Hash Table, Simulation
2751 Robot Collisions C++ Python O(nlogn) O(n) Hard Sort, Simulation, Stack
2934 Minimum Operations to Maximize Last Elements in Arrays C++ Python O(n) O(1) Medium Simulation
2960 Count Tested Devices After Test Operations C++ Python O(n) O(1) Easy Simulation
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


Constructive Algorithms

# Title Solution Time Space Difficulty Tag Note
2202 Maximize the Topmost Element After K Moves C++ Python O(min(n, k)) O(1) Medium Constructive Algorithms
2335 Minimum Amount of Time to Fill Cups C++ Python O(1) O(1) Easy Math, Constructive Algorithms
2350 Shortest Impossible Sequence of Rolls C++ Python O(n) O(k) Hard Constructive Algorithms
2546 Apply Bitwise Operations to Make Strings Equal C++ Python O(n) O(1) Medium Constructive Algorithms
2358 Maximum Number of Groups Entering a Competition C++ Python O(1) O(1) Medium Constructive Algorithms, Math
2610 Convert an Array Into a 2D Array With Conditions C++ Python O(n) O(n) Medium Freq Table, Constructive Algorithms
2647 Color the Triangle Red C++ Python O(n^2) O(1) Hard πŸ”’ Constructive Algorithms
2654 Minimum Number of Operations to Make All Array Elements Equal to 1 C++ Python O(n^2) O(1) Medium Math, Number Theory, Constructive Algorithms
2728 Count Houses in a Circular Street C++ Python O(k) O(1) Easy πŸ”’ Constructive Algorithms
2732 Find a Good Subset of the Matrix C++ Python O(m * 2^n) O(2^n) Hard Bitmasks, Constructive Algorithms, Greedy
2745 Construct the Longest New String C++ Python O(1) O(1) Medium Constructive Algorithms, Math
2753 Count Houses in a Circular Street II C++ Python O(k) O(1) Hard πŸ”’ Constructive Algorithms
2811 Check if it is Possible to Split Array C++ Python O(n) O(1) Medium Constructive Algorithms
2829 Determine the Minimum Sum of a k-avoiding Array C++ Python O(1) O(1) Medium Greedy, Constructive Algorithms, Math
2834 Find the Minimum Possible Sum of a Beautiful Array C++ Python O(1) O(1) Medium Determine the Minimum Sum of a k-avoiding Array Greedy, Constructive Algorithms, Math
2849 Determine if a Cell Is Reachable at a Given Time C++ Python O(1) O(1) Medium Constructive Algorithms, Math
2856 Minimum Array Length After Pair Removals C++ Python O(n) O(n) Medium Freq Table, Constructive Algorithms
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


Design

# Title Solution Time Space Difficulty Tag Note
2013 Detect Squares C++ Python ctor: O(1)
add: O(1)
count: O(n)
O(n) Medium
2034 Stock Price Fluctuation C++ Python ctor: O(1)
update: O(logn)
current: O(1)
max: O(1)
min: O(1)
O(n) Medium Sorted List, Heap
2043 Simple Bank System C++ Python ctor: O(1)
transer: O(1)
deposit: O(1)
withdraw: O(1)
O(1) Medium
2069 Walking Robot Simulation II C++ Python O(1) O(1) Medium Simulation, Math
2080 Range Frequency Queries C++ Python ctor: O(n)
query: O(logn)
O(n) Medium Binary Search
2102 Sequentially Ordinal Rank Tracker C++ Python add: O(logn)
get: O(logn)
O(n) Hard Sorted List
2166 Design Bitset C++ Python ctor: O(n)
fix: O(1)
fix: O(1)
unfix: O(1)
flip: O(1)
all: O(1)
one: O(1)
count: O(1)
toString: O(n)
O(n) Medium
2227 Encrypt and Decrypt Strings C++ Python ctor: O(m + d)
encrypt: O(n)
decrypt: O(n)
O(n) Hard Freq Table
2241 Design an ATM Machine C++ Python ctor: O(1)
deposit: O(1)
withdraw: O(1)
O(1) Medium Greedy
2254 Design Video Sharing Platform C++ Python ctor: O(1)
upload: O(logn + l)
remove: O(logn)
like: O(1)
dislike: O(1)
view: O(1)
getLikesAndDislikes: O(1)
getViews: O(1)
O(n * l) Hard πŸ”’ Heap
2276 Count Integers in Intervals C++ Python ctor: O(1)
add: O(logn), amortized
Count: O(1)
O(n) Hard Sorted List
2286 Booking Concert Tickets in Groups C++ Python ctor: O(n)
gather: O(logn)
scatter: O(logn), amortized
O(n) Hard Segment Tree, Binary Search
2296 Design a Text Editor C++ Python ctor: O(1)
addText: O(l)
deleteText: O(k)
cursorLeft: O(k)
cursorRight: O(k)
O(n) Hard Stack
2336 Smallest Number in Infinite Set C++ Python ctor: O(1)
popSmallest: O(logn)
addBack: O(logn)
O(n) Medium Heap, BST
2349 Design a Number Container System C++ Python ctor: O(1)
change: O(logn)
find: O(1)
O(n) Medium Sorted List, BST
2353 Design a Food Rating System C++ Python ctor: O(nlogn)
changeRating: O(logn)
highestRated: O(1)
O(n) Medium Sorted List, BST
2408 Design SQL C++ Python ctor: O(t * max_m)
insertRow: O(m)
deleteRow: O(1)
selectCell: O(m)
O(d) Medium πŸ”’ Hash Table
2424 Longest Uploaded Prefix C++ Python ctor: O(1)
upload: O(1), amortized
longest: O(1)
O(n) Medium Hash Table
2502 Design Memory Allocator C++ Python ctor: O(1)
allocate: O(logn)
free: O(logn)
O(n) Medium Sorted List
2526 Find Consecutive Integers from a Data Stream C++ Python O(1) O(1) Medium Array
2590 Design a Todo List C++ Python ctor: O(1)
addTask: O(l + logn)
getAllTasks: O(r)
getTasksForTag: O(r * c)
completeTask: O(l + logn)
O(n * l) Medium πŸ”’ BST, Sorted List
2642 Design Graph With Shortest Path Calculator C++ Python ctor: O(|V| + |E|)
addEdge: O(1)
shortestPath: O(|E| * log|V|)
O(|E|) Hard Dijkstra's Algorithm
2671 Frequency Tracker C++ Python ctor: O(1)
add: O(1)
deleteOne: O(1)
hasFrequency: O(1)
O(min(n, r)) Medium Freq Table
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


JS

# Title Solution Time Space Difficulty Tag Note
2618 Check if Object Instance of Class TypeScript O(n) O(1) Medium
2619 Array Prototype Last TypeScript O(1) O(1) Easy
2620 Counter TypeScript O(1) O(1) Easy
2621 Sleep TypeScript O(1) O(1) Easy Promise
2622 Cache With Time Limit TypeScript O(1) O(1) Medium Hash Table
2623 Memoize TypeScript O(1) O(1) Medium Hash Table
2624 Snail traversal TypeScript O(m * n) O(1) Medium
2625 Flatten Deeply Nested Array TypeScript O(n) O(h) Medium DFS
2626 Array Reduce Transformation TypeScript O(n) O(1) Easy
2627 Debounce TypeScript O(1) O(1) Medium
2628 JSON Deep Equal TypeScript O(n) O(h) Medium DFS
2629 Function Composition TypeScript O(n) O(1) Easy
2630 Memoize II TypeScript O(n) O(t) Hard Trie
2631 Group By TypeScript O(n) O(1) Medium
2632 Curry TypeScript O(n) O(n) Medium
2633 Convert Object to JSON String TypeScript O(n) O(h) Medium DFS
2634 Filter Elements from Array TypeScript O(n) O(1) Easy
2635 Apply Transform Over Each Element in Array TypeScript O(n) O(1) Easy
2636 Promise Pool TypeScript O(c + n / c) O(c) Medium Promise
2637 Promise Time Limit TypeScript O(n) O(1) Easy Promise
2648 Generate Fibonacci Sequence TypeScript O(1) O(1) Easy DP
2649 Nested Array Generator TypeScript O(1) O(d) Medium DFS
2650 Design Cancellable Function TypeScript O(1) O(1) Hard Promise
2665 Counter II TypeScript ctor: O(1)
increment: O(1)
decrement: O(1)
reset: O(1)
O(1) Easy
2666 Allow One Function Call TypeScript O(1) O(1) Easy
2667 Create Hello World Function TypeScript O(1) O(1) Easy
2675 Array of Objects to Matrix TypeScript O(l * mlogm + m * n) O(l * m + m * n) Medium DFS
2676 Throttle TypeScript O(1) O(1) Medium
2677 Chunk Array TypeScript O(n) O(1) Easy
2690 Infinite Method Object TypeScript O(1) O(1) Medium πŸ”’ Proxy
2691 Immutability Helper TypeScript O(1) O(1) Hard πŸ”’ Proxy
2692 Make Object Immutable TypeScript O(1) O(1) Medium πŸ”’ Proxy
2693 Call Function with Custom Context TypeScript O(1) O(1) Medium Symbol
2694 Event Emitter TypeScript subscribe: O(1)
unsubscribe: O(1)
emit: O(n)
O(n) Medium Ordered Set
2695 Array Wrapper TypeScript valueOf: O(n)
toString: O(n)
O(1) Easy
2700 Differences Between Two Objects TypeScript O(n) O(h) Medium DFS
2703 Return Length of Arguments Passed TypeScript O(1) O(1) Easy
2704 To Be Or Not To Be TypeScript O(1) O(1) Easy
2705 Compact Object TypeScript O(n) O(h) Medium DFS
2715 Execute Cancellable Function With Delay TypeScript O(1) O(1) Easy
2721 Execute Asynchronous Functions in Parallel TypeScript O(n) O(n) Medium Promise
2722 Join Two Arrays by ID TypeScript O(mlogm + nlogn) O(1) Medium Sort, Two Pointers
2723 Add Two Promises TypeScript O(1) O(1) Easy Promise
2724 Sort By TypeScript O(nlogn) O(1) Easy Sort
2725 Interval Cancellation TypeScript O(1) O(1) Easy
2726 Calculator with Method Chaining TypeScript O(1) O(1) Easy
2727 Is Object Empty TypeScript O(1) O(1) Easy
2754 Bind Function to Context TypeScript O(1) O(1) Medium πŸ”’ Symbol
2755 Deep Merge of Two Objects TypeScript O(n + m) O(h) Medium πŸ”’ DFS
2756 Query Batching TypeScript O(n) O(n) Hard πŸ”’
2757 Generate Circular Array Values TypeScript O(1) O(1) Medium πŸ”’ Generator
2758 Next Day TypeScript O(1) O(1) Easy πŸ”’
2759 Convert JSON String to Object TypeScript O(n) O(h) Hard πŸ”’ Stack
2774 Array Upper Bound TypeScript O(logn) O(1) Easy πŸ”’ Binary Search
2775 Undefined to Null TypeScript O(n) O(h) Medium πŸ”’ DFS
2776 Convert Callback Based Function to Promise Based Function TypeScript O(1) O(1) Medium πŸ”’ Promise
2777 Date Range Generator TypeScript O(1) O(1) Medium πŸ”’ Generator
2794 Create Object from Two Arrays TypeScript O(n) O(1) Easy πŸ”’
2795 Parallel Execution of Promises for Individual Results Retrieval TypeScript O(n) O(n) Medium πŸ”’ Promise
2796 Repeat String TypeScript O(n * t) O(n * t) Easy πŸ”’ String
2797 Partial Function with Placeholders TypeScript O(n) O(n) Medium πŸ”’
2803 Factorial Generator TypeScript O(n) O(1) Easy πŸ”’ Generator
2804 Array Prototype ForEach TypeScript O(n) O(1) Easy πŸ”’ Symbol
2805 Custom Interval TypeScript O(1) O(1) Medium πŸ”’
2821 Delay the Resolution of Each Promise TypeScript O(1) O(1) Easy πŸ”’ Promise
2822 Inversion of Object TypeScript O(n) O(1) Easy πŸ”’
2823 Deep Object Filter TypeScript O(n) O(h) Medium πŸ”’ DFS


SQL

# Title Solution Time Space Difficulty Tag Note
2004 The Number of Seniors and Juniors to Join the Company MySQL O(nlogn) O(n) Hard πŸ”’
2010 The Number of Seniors and Juniors to Join the Company II MySQL O(nlogn) O(n) Hard πŸ”’
2020 Number of Accounts That Did Not Stream MySQL O(m + n) O(m + n) Medium πŸ”’
2026 Low-Quality Problems MySQL O(nlogn) O(n) Easy πŸ”’
2041 Accepted Candidates From the Interviews MySQL O(m + n) O(m + n) Medium πŸ”’
2051 The Category of Each Member in the Store MySQL O(m + n) O(m + n) Medium πŸ”’
2066 Account Balance MySQL O(nlogn) O(n) Medium πŸ”’
2072 The Winner University MySQL O(n) O(n) Easy πŸ”’
2082 The Number of Rich Customers MySQL O(n) O(n) Easy πŸ”’
2084 Drop Type 1 Orders for Customers With Type 0 Orders MySQL O(nlogn) O(n) Medium πŸ”’
2112 The Airport With the Most Traffic MySQL O(n) O(n) Medium πŸ”’
2118 Build the Equation MySQL O(nlogn) O(n) Hard πŸ”’
2142 The Number of Passengers in Each Bus I MySQL O(p * b + blogb) O(p * b) Medium πŸ”’
2153 The Number of Passengers in Each Bus II MySQL O(p * b + blogb) O(p * b) Hard πŸ”’
2159 Order Two Columns Independently MySQL O(nlogn) O(n) Medium πŸ”’
2173 Longest Winning Streak MySQL O(nlogn) O(n) Hard πŸ”’
2175 The Change in Global Rankings MySQL O(nlogn) O(n) Medium πŸ”’
2199 Finding the Topic of Each Post MySQL O(n * mlogm) O(n * m) Hard πŸ”’
2205 The Number of Users That Are Eligible for Discount MySQL O(n) O(n) Easy πŸ”’
2228 Users With Two Purchases Within Seven Days MySQL O(nlogn) O(n) Medium πŸ”’
2230 The Users That Are Eligible for Discount MySQL O(nlogn) O(n) Easy πŸ”’
2238 Number of Times a Driver Was a Passenger MySQL O(n) O(n) Medium πŸ”’
2252 Dynamic Pivoting of a Table MySQL O(n * m) O(n * m) Hard πŸ”’
2253 Dynamic Unpivoting of a Table MySQL O(n * m) O(n * m) Hard πŸ”’
2292 Products With Three or More Orders in Two Consecutive Years MySQL O(nlogn) O(n) Medium πŸ”’
2298 Tasks Count in the Weekend MySQL O(n) O(n) Medium πŸ”’
2308 Arrange Table by Gender MySQL O(nlogn) O(n) Medium πŸ”’
2314 The First Day of the Maximum Recorded Degree in Each City MySQL O(nlogn) O(n) Medium πŸ”’
2324 Product Sales Analysis IV MySQL O(nlogn) O(n) Medium πŸ”’
2329 Product Sales Analysis V MySQL O(nlogn) O(n) Medium πŸ”’
2339 All the Matches of the League MySQL O(n^2) O(n^2) Easy πŸ”’
2346 Compute the Rank as a Percentage MySQL O(nlogn) O(n) Medium πŸ”’
2356 Number of Unique Subjects Taught by Each Teacher MySQL O(n) O(n) Easy πŸ”’
2362 Generate the Invoice MySQL O(m + nlogn) O(n + m) Hard πŸ”’
2372 Calculate the Influence of Each Salesperson MySQL O(sp + c + s) O(sp + c + s) Medium πŸ”’
2377 Sort the Olympic Table MySQL O(nlogn) O(n) Easy πŸ”’
2388 Change Null Values in a Table to the Previous Value MySQL O(nlogn) O(n) Medium πŸ”’
2394 Employees With Deductions MySQL O(n) O(n) Medium πŸ”’
2474 Customers With Strictly Increasing Purchases MySQL O(n) O(n) Hard πŸ”’
2480 Form a Chemical Bond MySQL O(n^2) O(n) Easy πŸ”’
2494 Merge Overlapping Events in the Same Hall MySQL O(nlogn) O(n) Hard πŸ”’
2504 Concatenate the Name and the Profession MySQL O(nlogn) O(n) Easy πŸ”’
2668 Find Latest Salaries MySQL O(nlogn) O(n) Easy πŸ”’
2669 Count Artist Occurrences On Spotify Ranking List MySQL O(nlogn) O(n) Easy πŸ”’
2686 Immediate Food Delivery III MySQL O(nlogn) O(n) Medium πŸ”’
2687 Bikes Last Time Used MySQL O(nlogn) O(n) Easy πŸ”’
2688 Find Active Users MySQL O(nlogn) O(n) Medium πŸ”’
2701 Consecutive Transactions with Increasing Amounts MySQL O(nlogn) O(n) Hard πŸ”’
2720 Popularity Percentage MySQL O(n^2) O(n^2) Hard πŸ”’
2738 Count Occurrences in Text MySQL O(n) O(n) Medium πŸ”’
2752 Customers with Maximum Number of Transactions on Consecutive Days MySQL O(nlogn) O(n) Hard πŸ”’
2783 Flight Occupancy and Waitlist Analysis MySQL O(n * m + nlogn) O(n * m) Medium πŸ”’
2793 Status of Flight Tickets MySQL O(nlogn + m) O(n + m) Hard πŸ”’
2820 Election Results MySQL O(nlogn) O(n) Medium πŸ”’
2837 Total Traveled Distance MySQL O(nlogn) O(n) Easy πŸ”’
2853 Highest Salaries Difference MySQL O(n) O(n) Easy πŸ”’
2854 Rolling Average Steps MySQL O(nlogn) O(n) Medium πŸ”’
2893 Calculate Orders Within Each Interval MySQL O(nlogn) O(n) Medium πŸ”’
2922 Market Analysis III MySQL O(nlogn) O(n) Medium πŸ”’
2978 Symmetric Coordinates MySQL O(nlogn) O(n) Medium πŸ”’
2984 Find Peak Calling Hours for Each City MySQL O(nlogn) O(n) Medium πŸ”’
2985 Calculate Compressed Mean MySQL O(n) O(n) Easy πŸ”’
2986 Find Third Transaction MySQL O(nlogn) O(n) Medium πŸ”’
2987 Find Expensive Cities MySQL O(nlogn) O(n) Easy πŸ”’
2988 Manager of the Largest Department MySQL O(nlogn) O(n) Medium πŸ”’
2989 Class Performance MySQL O(n) O(n) Medium πŸ”’
2990 Loan Types MySQL O(nlogn) O(n) Easy πŸ”’
2991 Top Three Wineries MySQL O(nlogn) O(n) Hard πŸ”’
2993 Friday Purchases I MySQL O(nlogn) O(n) Medium πŸ”’
2994 Friday Purchases II MySQL O(nlogn) O(n) Hard πŸ”’
2995 Viewers Turned Streamers MySQL O(nlogn) O(n) Hard πŸ”’
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(p + t) O(p + t) Hard πŸ”’

PD

# Title Solution Time Space Difficulty Tag Note
2877 Create a DataFrame from List Python3 O(n) O(1) Easy
2878 Get the Size of a DataFrame Python3 O(1) O(1) Easy
2879 Display the First Three Rows Python3 O(1) O(1) Easy
2880 Select Data Python3 O(n) O(n) Easy
2881 Create a New Column Python3 O(n) O(1) Easy
2882 Drop Duplicate Rows Python3 O(n) O(n) Easy
2883 Drop Missing Data Python3 O(n) O(1) Easy
2884 Modify Columns Python3 O(n) O(1) Easy
2885 Rename Columns Python3 O(n) O(1) Easy
2886 Change Data Type Python3 O(n) O(1) Easy
2887 Fill Missing Data Python3 O(n) O(1) Easy
2888 Reshape Data: Concatenate Python3 O(n + m) O(1) Easy
2889 Reshape Data: Pivot Python3 O(n) O(1) Easy
2890 Reshape Data: Melt Python3 O(n) O(1) Easy
2891 Method Chaining Python3 O(nlogn) O(n) Easy