Skip to content

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

License

Notifications You must be signed in to change notification settings

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

Shell

Reference

Bit Manipulation

# Title Solution Time Space Difficulty Tag Note
1310 XOR Queries of a Subarray C++ Python O(n) O(1) Medium
1318 Minimum Flips to Make a OR b Equal to c C++ Python O(1) O(1) Medium
1342 Number of Steps to Reduce a Number to Zero C++ Python O(logn) O(1) Easy
1558 Minimum Numbers of Function Calls to Make Target Array C++ Python O(nlogn) O(1) Medium Greedy
1707 Maximum XOR With an Element From Array C++ Python O(nlogn + mlogm + nlogk + mlogk) O(nlogk) Hard variant of Maximum XOR of Two Numbers in an Array Greedy, Trie
1720 Decode XORed Array C++ Python O(n) O(1) Easy
1734 Decode XORed Permutation C++ Python O(n) O(1) Medium
1829 Maximum XOR for Each Query C++ Python O(n) O(1) Medium
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


Array

# Title Solution Time Space Difficulty Tag Note
1002 Find Common Characters C++ Python O(n * l) O(1) Easy
1007 Minimum Domino Rotations For Equal Row C++ Python O(n) O(1) Medium
1010 Pairs of Songs With Total Durations Divisible by 60 C++ Python O(n) O(1) Easy
1013 Partition Array Into Three Parts With Equal Sum C++ Python O(n) O(1) Easy
1014 Best Sightseeing Pair C++ Python O(n) O(1) Medium
1018 Binary Prefix Divisible By 5 C++ Python O(n) O(1) Easy
1030 Matrix Cells in Distance Order C++ Python O(m * n) O(1) Easy
1031 Maximum Sum of Two Non-Overlapping Subarrays C++ Python O(n) O(1) Medium
1051 Height Checker C++ Python O(nlogn) O(n) Easy
1052 Grumpy Bookstore Owner C++ Python O(n) O(1) Medium
1072 Flip Columns For Maximum Number of Equal Rows C++ Python O(m * n) O(m * n) Medium
1074 Number of Submatrices That Sum to Target C++ Python O(m^2 * n) O(n) Hard
1085 Sum of Digits in the Minimum Number C++ Python O(n * l) O(l) Easy πŸ”’
1089 Duplicate Zeros C++ Python O(n) O(1) Easy
1093 Statistics from a Large Sample C++ Python O(n) O(1) Medium
1099 Two Sum Less Than K C++ Python O(nlogn) O(1) Easy πŸ”’
1109 Corporate Flight Bookings C++ Python O(n) O(1) Medium Line Sweep
1144 Decrease Elements To Make Array Zigzag C++ Python O(n) O(1) Medium
1184 Distance Between Bus Stops C++ Python O(n) O(1) Easy
1200 Minimum Absolute Difference C++ Python O(nlogn) O(n) Easy
1222 Queens That Can Attack the King C++ Python O(1) O(1) Medium
1252 Cells with Odd Values in a Matrix C++ Python O(n + m) O(n + m) Easy
1260 Shift 2D Grid C++ Python O(n) O(1) Easy
1267 Count Servers that Communicate C++ Python O(m * n) O(m + n) Medium
1275 Find Winner on a Tic Tac Toe Game C++ Python O(1) O(1) Easy
1295 Find Numbers with Even Number of Digits C++ Python O(nlog(logm)) O(logm) Easy
1299 Replace Elements with Greatest Element on Right Side C++ Python O(n) O(1) Easy
1304 Find N Unique Integers Sum up to Zero C++ Python O(n) O(1) Easy
1313 Decompress Run-Length Encoded List C++ Python O(n) O(1) Easy
1329 Sort the Matrix Diagonally C++ Python O(m * n * log(min(m, n)) O(m * n) Medium Sort
1331 Rank Transform of an Array C++ Python O(nlogn) O(n) Easy
1333 Filter Restaurants by Vegan-Friendly, Price and Distance C++ Python O(rlogr) O(r) Medium Sort
1337 The K Weakest Rows in a Matrix C++ Python O(m * n) O(k) Easy OrderedDict, Quick Select
1343 Number of Sub-arrays of Size K and Average Greater than or Equal to Threshold C++ Python O(n) O(1) Medium
1346 Check If N and Its Double Exist C++ Python O(n) O(n) Easy
1351 Count Negative Numbers in a Sorted Matrix C++ Python O(m + n) O(1) Easy
1375 Bulb Switcher III C++ Python O(n) O(1) Medium
1380 Lucky Numbers in a Matrix C++ Python O(m * n) O(m + n) Easy
1389 Create Target Array in the Given Order C++ Python O(n^2) O(1) Easy
1394 Find Lucky Integer in an Array C++ Python O(n) O(n) Easy
1399 Count Largest Group C++ Python O(nlogn) O(n) Easy
1404 Number of Steps to Reduce a Number in Binary Representation to One C++ Python O(n) O(1) Medium
1413 Minimum Value to Get Positive Step by Step Sum C++ Python O(n) O(1) Easy
1426 Counting Elements C++ Python O(n) O(n) Easy πŸ”’
1427 Perform String Shifts C++ Python O(n + l) O(1) Easy πŸ”’
1428 Leftmost Column with at Least a One C++ Python O(m + n) O(1) Medium πŸ”’
1431 Kids With the Greatest Number of Candies C++ Python O(n) O(1) Easy
1437 Check If All 1's Are at Least Length K Places Away C++ Python O(n) O(1) Medium
1450 Number of Students Doing Homework at a Given Time C++ Python O(n) O(1) Easy
1460 Make Two Arrays Equal by Reversing Sub-arrays C++ Python O(n) O(n) Easy
1464 Maximum Product of Two Elements in an Array C++ Python O(n) O(1) Easy
1465 Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts C++ Python O(hlogh + wlogw) O(1) Medium
1470 Shuffle the Array C++ Python O(n) O(1) Easy Inplace
1471 The k Strongest Values in an Array C++ Python O(n) O(1) Medium Quick Select
1475 Final Prices With a Special Discount in a Shop C++ Python O(n) O(n) Easy Mono Stack
1480 Running Sum of 1d Array C++ Python O(n) O(1) Easy
1491 Average Salary Excluding the Minimum and Maximum Salary C++ Python O(n) O(1) Easy
1502 Can Make Arithmetic Progression From Sequence C++ Python O(n) O(1) Easy
1503 Last Moment Before All Ants Fall Out of a Plank C++ Python O(n) O(1) Medium
1534 Count Good Triplets C++ Python O(n^3) O(1) Easy
1535 Find the Winner of an Array Game C++ Python O(n) O(1) Medium
1538 Guess the Majority in a Hidden Array C++ Python O(n) O(1) Medium πŸ”’
1550 Three Consecutive Odds C++ Python O(n) O(1) Easy
1559 Detect Cycles in 2D Grid C++ Python O(m * n) O(m * n) Hard Union Find, BFS
1560 Most Visited Sector in a Circular Track C++ Python O(n) O(1) Easy
1562 Find Latest Group of Size M C++ Python O(n) O(n) Medium
1566 Detect Pattern of Length M Repeated K or More Times C++ Python O(n) O(1) Easy
1572 Matrix Diagonal Sum C++ Python O(n) O(1) Easy
1574 Shortest Subarray to be Removed to Make Array Sorted C++ Python O(n) O(1) Medium
1582 Special Positions in a Binary Matrix C++ Python O(n^2) O(n) Easy
1583 Count Unhappy Friends C++ Python O(n^2) O(n^2) Medium
1619 Mean of Array After Removing Some Elements C++ Python O(n) O(1) Easy Quick Select
1629 Slowest Key C++ Python O(n) O(1) Easy
1646 Get Maximum in Generated Array C++ Python O(n) O(n) Easy
1652 Defuse the Bomb C++ Python O(n) O(1) Easy
1672 Richest Customer Wealth C++ Python O(m * n) O(1) Easy
1700 Number of Students Unable to Eat Lunch C++ Python O(n) O(1) Easy
1701 Average Waiting Time C++ Python O(n) O(1) Medium
1706 Where Will the Ball Fall C++ Python O(m * n) O(1) Medium
1714 Sum Of Special Evenly-Spaced Elements In Array C++ Python O(n * sqrt(n)) O(n * sqrt(n)) Hard πŸ”’
1726 Tuple with Same Product C++ Python O(n^2) O(n^2) Medium
1732 Find the Highest Altitude C++ Python O(n) O(1) Medium
1738 Find Kth Largest XOR Coordinate Value C++ Python O(m * n) on average O(m * n) Medium Quick Select
1742 Maximum Number of Balls in a Box C++ Python O(nlogm) O(logm) Easy
1752 Check if Array Is Sorted and Rotated C++ Python O(n) O(1) Easy
1755 Closest Subsequence Sum C++ Python O(n * 2^(n/2)) O(2^(n/2)) Hard Meet in the Middle
1773 Count Items Matching a Rule C++ Python O(n) O(1) Easy
1779 Find Nearest Point That Has the Same X or Y Coordinate C++ Python O(n) O(1) Easy
1800 Maximum Ascending Subarray Sum C++ Python O(n) O(1) Easy
1826 Faulty Sensor C++ Python O(n) O(1) Easy πŸ”’
1848 Minimum Distance to the Target Element C++ Python O(n) O(1) Easy
1861 Rotating the Box C++ Python O(m * n) O(1) Medium
1869 Longer Contiguous Segments of Ones than Zeros C++ Python O(n) O(1) Easy
1878 Get Biggest Three Rhombus Sums in a Grid C++ Python O(m * n * min(m, n)) O(m * n) Easy
1886 Determine Whether Matrix Can Be Obtained By Rotation C++ Python O(m * n) O(1) Easy
1895 Largest Magic Square C++ Python O(max(m, n) * min(m, n)^3) O(m * n) Medium
1906 Minimum Absolute Difference Queries C++ Python O(r * (n + q)) O(r * n) Medium Prefix Sum, Binary Search
1909 Remove One Element to Make the Array Strictly Increasing C++ Python O(n) O(1) Easy
1914 Cyclically Rotating a Grid C++ Python O(m * n) O(1) Medium Inplace
1920 Build Array from Permutation C++ Python O(n) O(1) Easy Inplace
1929 Concatenation of Array C++ Python O(n) O(1) Easy
1940 Longest Common Subsequence Between Sorted Arrays C++ Python O(m * n) O(l) Medium πŸ”’
1958 Check if Move is Legal C++ Python O(1) O(1) Medium
1966 Binary Searchable Numbers in an Unsorted Array C++ Python O(n) O(n) Medium πŸ”’ Prefix Sum
1970 Last Day Where You Can Still Cross C++ Python O(m * n) O(m * n) Hard variant of Bricks Falling When Hit Union Find
1983 Widest Pair of Indices With Equal Range Sum C++ Python O(n) O(n) Medium variant of Find the Longest Substring Containing Vowels in Even Counts, πŸ”’ Prefix Sum
1991 Find the Middle Index in Array C++ Python O(n) O(1) Easy Prefix Sum
1992 Find All Groups of Farmland C++ Python O(m * n) O(1) Medium variant of Number of Islands
1998 GCD Sort of an Array C++ Python O(nlogn + m) O(n + m) Hard Union Find, Sieve of Eratosthenes
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


String

# Title Solution Time Space Difficulty Tag Note
1016 Binary String With Substrings Representing 1 To N C++ Python O(n^2) O(1) Medium
1023 Camelcase Matching C++ Python O(n * l) O(1) Medium
1061 Lexicographically Smallest Equivalent String C++ Python O(n) O(n) Medium πŸ”’ Union Find
1056 Confusing Number C++ Python O(logn) O(logn) Easy πŸ”’
1071 Greatest Common Divisor of Strings C++ Python O(m + n) O(1) Easy
1078 Occurrences After Bigram C++ Python O(n) O(1) Easy
1100 Find K-Length Substrings With No Repeated Characters C++ Python O(n) O(k) Medium πŸ”’
1108 Defanging an IP Address C++ Python O(n) O(1) Easy
1119 Remove Vowels from a String C++ Python O(n) O(1) Easy πŸ”’
1147 Longest Chunked Palindrome Decomposition C++ Python O(n) O(1) Hard Rabin-Karp Algorithm
1177 Can Make Palindrome from Substring C++ Python O(m + n) O(n) Medium
1178 Number of Valid Words for Each Puzzle C++ Python O(n * l + m * L) O(L!) Hard Trie, Bit Manipulation
1189 Maximum Number of Balloons C++ Python O(n) O(1) Easy Hash
1233 Remove Sub-Folders from the Filesystem C++ Python O(n) O(t) Medium Trie
1271 Hexspeak C++ Python O(n) O(1) Easy
1309 Decrypt String from Alphabet to Integer Mapping C++ Python O(n) O(1) Easy
1324 Print Words Vertically C++ Python O(n) O(n) Medium
1328 Break a Palindrome C++ Python O(n) O(1) Medium
1332 Remove Palindromic Subsequences C++ Python O(n) O(1) Easy
1347 Minimum Number of Steps to Make Two Strings Anagram C++ Python O(n) O(1) Medium
1370 Increasing Decreasing String C++ Python O(n) O(1) Easy Sort
1371 Find the Longest Substring Containing Vowels in Even Counts C++ Python O(n) O(1) Medium
1374 Generate a String With Characters That Have Odd Count C++ Python O(n) O(1) Easy
1392 Longest Happy Prefix C++ Python O(n) O(n) Hard KMP Algorithm, Rabin-Karp Algorithm
1408 String Matching in an Array C++ Python O(n) O(t) Easy KMP Algorithm, Aho-Corasick Automata, Trie
1410 HTML Entity Parser C++ Python O(n) O(t) Medium Aho-Corasick Automata, Trie
1417 Reformat The String C++ Python O(n) O(1) Easy
1422 Maximum Score After Splitting a String C++ Python O(n) O(1) Easy
1432 Max Difference You Can Get From Changing an Integer C++ Python O(logn) O(logn) Medium
1436 Destination City C++ Python O(n) O(n) Easy
1446 Consecutive Characters C++ Python O(n) O(1) Easy
1455 Check If a Word Occurs As a Prefix of Any Word in a Sentence C++ Python O(n) O(n) Easy KMP Algorithm
1461 Check If a String Contains All Binary Codes of Size K C++ Python O(n * k) O(k * 2^k) Medium Bit Manipulation
1496 Path Crossing C++ Python O(n) O(n) Easy
1507 Reformat Date C++ Python O(n) O(1) Easy
1528 Shuffle String C++ Python O(n) O(1) Easy
1529 Bulb Switcher IV C++ Python O(n) O(1) Medium
1540 Can Convert String in K Moves C++ Python O(n) O(1) Medium
1542 Find Longest Awesome Substring C++ Python O(n) O(1) Hard
1544 Make The String Great C++ Python O(n) O(1) Easy
1545 Find Kth Bit in Nth Binary String C++ Python O(n) O(1) Medium
1554 Strings Differ by One Character C++ Python O(n * m) O(n) Medium Rabin-Karp Algorithm
1556 Thousand Separator C++ Python O(n) O(1) Easy
1573 Number of Ways to Split a String C++ Python O(n) O(1) Medium
1576 Replace All ?'s to Avoid Consecutive Repeating Characters C++ Python O(n) O(1) Easy
1592 Rearrange Spaces Between Words C++ Python O(n) O(1) Easy Inplace
1598 Crawler Log Folder C++ Python O(n) O(1) Easy
1614 Maximum Nesting Depth of the Parentheses C++ Python O(n) O(1) Easy
1624 Largest Substring Between Two Equal Characters C++ Python O(n) O(1) Easy
1638 Count Substrings That Differ by One Character C++ Python O(m * n) O(1) Medium variant of Count Unique Characters of All Substrings of a Given String Tricky
1662 Check If Two String Arrays are Equivalent C++ Python O(n) O(1) Easy
1668 Maximum Repeating Substring C++ Python O(n) O(m) Easy KMP Algorithm
1678 Goal Parser Interpretation C++ Python O(n) O(1) Easy
1684 Count the Number of Consistent Strings C++ Python O(n) O(1) Easy
1694 Reformat Phone Number C++ Python O(n) O(1) Easy Inplace
1698 Number of Distinct Substrings in a String C++ Python O(n^2) O(t) Medium πŸ”’ Trie
1704 Determine if String Halves Are Alike C++ Python O(n) O(1) Easy
1763 Longest Nice Substring C++ Python O(n) O(n) Easy
1768 Merge Strings Alternately C++ Python O(m + n) O(1) Easy
1784 Check if Binary String Has at Most One Segment of Ones C++ Python O(n) O(1) Easy
1790 Check if One String Swap Can Make Strings Equal C++ Python O(n) O(1) Easy
1796 Second Largest Digit in a String C++ Python O(n) O(1) Easy
1805 Number of Different Integers in a String C++ Python O(n) O(n) Easy
1813 Sentence Similarity III C++ Python O(n) O(1) Medium
1816 Truncate Sentence C++ Python O(n) O(1) Easy
1832 Check if the Sentence Is Pangram C++ Python O(n) O(1) Easy
1839 Longest Substring Of All Vowels in Order C++ Python O(n) O(1) Medium
1844 Replace All Digits with Characters C++ Python O(n) O(1) Easy
1854 Maximum Population Year C++ Python O(n) O(1) Easy Line Sweep
1858 Longest Word With All Prefixes C++ Python O(n) O(t) Medium πŸ”’ Trie, DFS
1876 Substrings of Size Three with Distinct Characters C++ Python O(n) O(1) Easy
1880 Check if Word Equals Summation of Two Words C++ Python O(n) O(1) Easy
1903 Largest Odd Number in String C++ Python O(n) O(1) Easy
1910 Remove All Occurrences of a Substring C++ Python O(n + m) O(n + m) Medium KMP Algorithm
1933 Check if String Is Decomposable Into Value-Equal Substrings C++ Python O(n) O(1) Easy πŸ”’
1935 Maximum Number of Words You Can Type C++ Python O(n) O(1) Easy
1957 Delete Characters to Make Fancy String C++ Python O(n) O(1) Easy Inplace
1961 Check If String Is a Prefix of Array C++ Python O(n) O(1) Easy
1963 Minimum Number of Swaps to Make the String Balanced C++ Python O(n) O(1) Medium variant of Maximum Nesting Depth of the Parentheses
1967 Number of Strings That Appear as Substrings in Word C++ Python O(n * l + m) O(t) Easy KMP Algorithm, Aho-Corasick Automata, Trie
1974 Minimum Time to Type Word Using Special Typewriter C++ Python O(n) O(1) Easy
2000 Reverse Prefix of Word C++ Python O(n) O(1) Easy
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


Linked List

# Title Solution Time Space Difficulty Tag Note
1171 Remove Zero Sum Consecutive Nodes from Linked List C++ Python O(n) O(n) Medium OrderedDict, Hash
1180 Count Substrings with Only One Distinct Letter C++ Python O(n) O(1) Easy πŸ”’
1181 Before and After Puzzle C++ Python O(l * rlogr) O(l * (n + r)) Medium πŸ”’ Hash
1265 Print Immutable Linked List in Reverse C++ Python O(n) O(sqrt(n)) Medium πŸ”’
1290 Convert Binary Number in a Linked List to Integer C++ Python O(n) O(1) Easy
1474 Delete N Nodes After M Nodes of a Linked List C++ Python O(n) O(1) Easy πŸ”’
1634 Add Two Polynomials Represented as Linked Lists C++ Python O(m + n) O(1) Medium πŸ”’
1650 Lowest Common Ancestor of a Binary Tree III C++ Python O(h) O(1) Medium πŸ”’, variant of Intersection of Two Linked Lists
1669 Merge In Between Linked Lists C++ Python O(m + n) O(1) Medium
1721 Swapping Nodes in a Linked List C++ Python O(n) O(1) Medium
1836 Remove Duplicates From an Unsorted Linked List C++ Python O(n) O(n) Medium πŸ”’
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


Stack

# Title Solution Time Space Difficulty Tag Note
1003 Check If Word Is Valid After Substitutions C++ Python O(n) O(n) Medium
1019 Next Greater Node In Linked List C++ Python O(n) O(n) Medium Mono Stack
1021 Remove Outermost Parentheses C++ Python O(n) O(1) Easy
1047 Remove All Adjacent Duplicates In String C++ Python O(n) O(n) Easy
1063 Number of Valid Subarrays C++ Python O(n) O(n) Hard πŸ”’ Mono Stack
1130 Minimum Cost Tree From Leaf Values C++ Python O(n) O(n) Medium Mono Stack
1190 Reverse Substrings Between Each Pair of Parentheses C++ Python O(n) O(n) Medium
1209 Remove All Adjacent Duplicates in String II C++ Python O(n) O(n) Medium
1441 Build an Array With Stack Operations C++ Python O(n) O(1) Easy
1541 Minimum Insertions to Balance a Parentheses String C++ Python O(n) O(1) Medium
1597 Build Binary Expression Tree From Infix Expression C++ Python O(n) O(n) Medium πŸ”’, variant of Basic Calculator III
1856 Maximum Subarray Min-Product C++ Python O(n) O(n) Medium variant of Largest Rectangle in Histogram Mono Stack, Prefix Sum
1944 Number of Visible People in a Queue C++ Python O(n) O(n) Hard variant of Buildings With an Ocean View Mono Stack
1950 Maximum of Minimum Values in All Subarrays C++ Python O(n) O(n) Medium πŸ”’ Mono Stack
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


Queue

# Title Solution Time Space Difficulty Tag Note
1424 Diagonal Traverse II C++ Python O(m * n) O(m) Medium
1438 Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit C++ Python O(n) O(n) Hard Mono Deque
1499 Max Value of Equation C++ Python O(n) O(n) Hard Mono Deque
1696 Jump Game VI C++ Python O(n) O(k) Medium Mono Deque, Sliding Window
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
1046 Last Stone Weight C++ Python O(nlogn) O(n) Easy
1057 Campus Bikes C++ Python O((w * b) * log(w * b)) O(w * b) Medium πŸ”’
1439 Find the Kth Smallest Sum of a Matrix With Sorted Rows C++ Python O(m * klogk) O(k) Hard Binary Search
1606 Find Servers That Handled Most Number of Requests C++ Python O(nlogk) O(k) Hard Sorted List
1642 Furthest Building You Can Reach C++ Python O(nlogk) O(k) Medium
1675 Minimize Deviation in Array C++ Python O((n * log(max_num)) * logn) O(n) Hard
1792 Maximum Average Pass Ratio C++ Python O(n + mlogn) O(n) Medium
1882 Process Tasks Using Servers C++ Python O(n + mlogn) O(n) Medium
1962 Remove Stones to Minimize the Total C++ Python O(n + klogn) O(1) Medium
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


Tree

# Title Solution Time Space Difficulty Tag Note
1008 Construct Binary Search Tree from Preorder Traversal C++ Python O(n) O(h) Medium
1022 Sum of Root To Leaf Binary Numbers C++ Python O(n) O(h) Easy
1026 Maximum Difference Between Node and Ancestor C++ Python O(n) O(h) Medium DFS
1028 Recover a Tree From Preorder Traversal C++ Python O(n) O(h) Hard DFS
1032 Stream of Characters C++ C++ Python Python ctor: O(n)
query: O(m)
O(t) Hard Aho-Corasick Automata, Trie
1038 Binary Search Tree to Greater Sum Tree C++ Python O(n) O(h) Medium DFS
1065 Index Pairs of a String C++ Python O(n + m + z) O(t) Easy πŸ”’ Aho-Corasick Automata, Trie
1080 Insufficient Nodes in Root to Leaf Paths C++ Python O(n) O(h) Medium DFS
1104 Path In Zigzag Labelled Binary Tree C++ Python O(logn) O(logn) Easy Math
1120 Maximum Average Subtree C++ Python O(n) O(h) Easy πŸ”’ DFS
1123 Lowest Common Ancestor of Deepest Leaves C++ Python O(n) O(h) Medium DFS
1145 Binary Tree Coloring Game C++ Python O(n) O(h) Medium DFS
1257 Smallest Common Region C++ Python O(m * n) O(n) Medium
1261 Find Elements in a Contaminated Binary Tree C++ Python O(n) O(h) Medium DFS
1325 Delete Leaves With a Given Value C++ Python O(n) O(h) Medium DFS
1339 Maximum Product of Splitted Binary Tree C++ Python O(n) O(h) Medium DFS
1409 Queries on a Permutation With Key C++ Python O(nlogn) O(n) Medium BIT, Fenwick Tree
1430 Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree C++ Python O(n) O(h) Medium πŸ”’ BFS, DFS, Stack
1443 Minimum Time to Collect All Apples in a Tree C++ Python O(n) O(n) Medium DFS, Stack
1448 Count Good Nodes in Binary Tree C++ Python O(n) O(h) Medium DFS, Stack
1457 Pseudo-Palindromic Paths in a Binary Tree C++ Python O(n) O(h) Medium DFS, Stack
1469 Find All The Lonely Nodes C++ Python O(n) O(h) Easy πŸ”’ DFS, Stack
1490 Clone N-ary Tree C++ Python O(n) O(h) Medium πŸ”’ DFS, Stack
1505 Minimum Possible Integer After at Most K Adjacent Swaps On Digits C++ Python O(nlogn) O(n) Hard BIT, Fenwick Tree
1506 Find Root of N-Ary Tree C++ Python O(n) O(1) Medium πŸ”’ Bit Manipulation
1516 Move Sub-Tree of N-Ary Tree C++ Python O(n) O(h) Hard πŸ”’ DFS, Stack
1519 Number of Nodes in the Sub-Tree With the Same Label C++ Python O(n) O(h) Medium DFS, Stack
1522 Diameter of N-Ary Tree C++ Python O(n) O(h) Medium πŸ”’ DFS, Stack
1530 Number of Good Leaf Nodes Pairs C++ Python O(n) O(h) Medium DFS, Stack
1612 Check If Two Expression Trees are Equivalent C++ Python O(n) O(1) Medium πŸ”’ Morris Traversal, Inorder Traversal, Stack, Hash Table
1649 Create Sorted Array through Instructions C++ Python O(nlogn) O(n) Hard variant of Count of Smaller Numbers After Self BIT, Fenwick Tree, Merge Sort
1666 Change the Root of a Binary Tree C++ Python O(h) O(1) Medium πŸ”’
1834 Single-Threaded CPU C++ Python O(nlogn) O(n) Medium
1938 Maximum Genetic Difference Query C++ Python O(nlogk + mlogk) O(n + logk) Hard variant of Maximum XOR With an Element From Array DFS, Greedy, Trie
1948 Delete Duplicate Folders in System C++ Python O(n * m * l + tlogt + l * t) O(l * t) Hard variant of Find Duplicate Subtrees Trie, DFS, Hash
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) 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


Hash Table

# Title Solution Time Space Difficulty Tag Note
1001 Grid Illumination C++ Python O(l + q) O(l) Hard
1124 Longest Well-Performing Interval C++ Python O(n) O(n) Medium
1133 Largest Unique Number C++ Python O(n) O(n) Easy πŸ”’ Hash
1152 Analyze User Website Visit Pattern C++ Python O(n^3) O(n^3) Medium πŸ”’ Hash
1153 String Transforms Into Another String C++ Python O(n) O(1) Hard πŸ”’ Hash
1160 Find Words That Can Be Formed by Characters C++ Python O(m * n) O(1) Easy
1165 Single-Row Keyboard C++ Python O(n) O(1) Easy πŸ”’
1198 Find Smallest Common Element in All Rows C++ Python O(m * n) O(n) Medium πŸ”’
1207 Unique Number of Occurrences C++ Python O(n) O(n) Easy
1224 Maximum Equal Frequency C++ Python O(n) O(n) Hard
1418 Display Table of Food Orders in a Restaurant C++ Python O(n + tlogt + flogf) O(n) Medium
1452 People Whose List of Favorite Companies Is Not a Subset of Another List C++ Python O(n * m * l + n^2 * m) O(n * m * l) Medium
1487 Making File Names Unique C++ Python O(n) O(n) Medium
1577 Number of Ways Where Square of Number Is Equal to Product of Two Numbers C++ Python O(m * n) O(m + n) Medium
1590 Make Sum Divisible by P C++ Python O(n) O(p) Medium variant of Subarray Sums Divisible by K
1640 Check Array Formation Through Concatenation C++ Python O(n) O(n) Easy
1657 Determine if Two Strings Are Close C++ Python O(n) O(1) Medium
1679 Max Number of K-Sum Pairs C++ Python O(n) O(n) Medium
1711 Count Good Meals C++ Python O(n) O(1) Medium
1748 Sum of Unique Elements C++ Python O(n) O(n) Easy
1781 Sum of Beauty of All Substrings C++ Python O(n^2) O(1) Medium
1807 Evaluate the Bracket Pairs of a String C++ Python O(n + m) O(n + m) Medium
1814 Count Nice Pairs in an Array C++ Python O(nlogm) O(n) Medium
1817 Finding the Users Active Minutes C++ Python O(n) O(n) Medium
1915 Number of Wonderful Substrings C++ Python O(n) O(1) Medium
1923 Longest Common Subpath C++ Python O(m * nlogn) O(n) Hard Binary Search, Rabin-Karp Algorithm
1925 Count Square Sum Triples C++ Python O(n^2) O(n) Easy
1930 Unique Length-3 Palindromic Subsequences C++ Python O(n) O(1) Medium
1941 Check if All Characters Have Equal Number of Occurrences C++ Python O(n) O(1) Easy
1995 Count Special Quadruplets C++ Python O(n^3) O(n) Easy variant of 4 Sum
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


Math

# Title Solution Time Space Difficulty Tag Note
1006 Clumsy Factorial C++ Python O(1) O(1) Medium
1009 Complement of Base 10 Integer C++ Python O(logn) O(1) Easy
1012 Numbers With Repeated Digits C++ Python O(logn) O(logn) Hard
1015 Smallest Integer Divisible by K C++ Python O(k) O(1) Medium
1017 Convert to Base -2 C++ Python O(logn) O(1) Medium
1025 Divisor Game C++ Python O(1) O(1) Easy DP
1037 Valid Boomerang C++ Python O(1) O(1) Easy
1041 Robot Bounded In Circle C++ Python O(n) O(1) Medium
1067 Digit Count in Range C++ Python O(logn) O(1) Hard πŸ”’, variant of Number of Digit One
1073 Adding Two Negabinary Numbers C++ Python O(n) O(n) Medium
1079 Letter Tile Possibilities C++ Python O(n^2) O(n) Medium Generating Function, Backtracking
1088 Confusing Number II C++ Python O(logn) O(logn) Hard πŸ”’
1103 Distribute Candies to People C++ Python O(n + logc) O(1) Easy Binary Search
1118 Number of Days in a Month C++ Python O(1) O(1) Easy πŸ”’
1121 Divide Array Into Increasing Sequences C++ Python O(n) O(1) Hard πŸ”’
1128 Number of Equivalent Domino Pairs C++ Python O(n) O(n) Easy
1131 Maximum of Absolute Value Expression C++ Python O(n) O(1) Medium
1134 Armstrong Number C++ Python O(klogk) O(k) Easy πŸ”’
1150 Check If a Number Is Majority Element in a Sorted Array C++ Python O(nlogn) O(1) Easy πŸ”’ Binary Search
1157 Online Majority Element In Subarray C++ Python ctor: O(n)
query: O(klogn)
O(n) Hard Binary Search, Segment Tree, Boyer–Moore Majority Vote Algorithm
1154 Day of the Year C++ Python O(1) O(1) Easy
1175 Prime Arrangements C++ Python O(nlog(logn)) O(n) Easy Sieve of Eratosthenes
1185 Day of the Week C++ Python O(1) O(1) Easy Zeller Formula
1197 Minimum Knight Moves C++ Python O(1) O(1) Medium πŸ”’ DP, Math
1217 Play with Chips C++ Python O(n) O(1) Medium
1227 Airplane Seat Assignment Probability C++ Python O(1) O(1) Medium
1232 Check If It Is a Straight Line C++ Python O(1) O(1) Easy
1237 Find Positive Integer Solution for a Given Equation C++ Python O(n) O(1) Easy
1238 Circular Permutation in Binary Representation C++ Python O(2^n) O(1) Medium variant of Gray Code
1250 Check If It Is a Good Array C++ Python O(n) O(1) Hard BΓ©zout's identity
1256 Encode Number C++ Python O(logn) O(1) Medium
1259 Handshakes That Don't Cross C++ Python O(n) O(1) Hard Catalan Number, DP
1266 Minimum Time Visiting All Points C++ Python O(n) O(1) Easy
1276 Number of Burgers with No Waste of Ingredients C++ Python O(1) O(1) Medium
1281 Subtract the Product and Sum of Digits of an Integer C++ Python O(logn) O(1) Easy
1300 Sum of Mutated Array Closest to Target C++ Python O(nlogn) O(1) Medium Binary Search
1317 Convert Integer to the Sum of Two No-Zero Integers C++ Python O(logn) O(1) Easy
1323 Maximum 69 Number C++ Python O(logn) O(1) Easy
1330 Reverse Subarray To Maximize Array Value C++ Python O(n) O(1) Hard
1344 Angle Between Hands of a Clock C++ Python O(1) O(1) Medium
1359 Count All Valid Pickup and Delivery Options C++ Python O(n) O(1) Hard
1360 Number of Days Between Two Dates C++ Python O(1) O(1) Easy variant of Day of the Year
1362 Closest Divisors C++ Python O(sqrt(n)) O(1) Medium
1363 Largest Multiple of Three C++ Python O(n) O(1) Hard
1390 Four Divisors C++ Python O(n * sqrt(n)) O(1) Medium
1401 Circle and Rectangle Overlapping C++ Python O(1) O(1) Medium
1415 The k-th Lexicographical String of All Happy Strings of Length n C++ Python O(n) O(1) Medium
1442 Count Triplets That Can Form Two Arrays of Equal XOR C++ Python O(n) O(n) Medium
1447 Simplified Fractions C++ Python O(n^2 * logn) O(n^2) Medium
1486 XOR Operation in an Array C++ Python O(1) O(1) Easy
1492 The kth Factor of n C++ Python O(sqrt(n)) O(1) Medium
1497 Check If Array Pairs Are Divisible by k C++ Python O(n) O(k) Medium
1512 Number of Good Pairs C++ Python O(n) O(1) Easy
1513 Number of Substrings With Only 1s C++ Python O(n) O(1) Medium
1525 Number of Good Ways to Split a String C++ Python O(n) O(1) Medium
1537 Get the Maximum Score C++ Python O(m + n) O(1) Hard
1551 Minimum Operations to Make Array Equal C++ Python O(1) O(1) Medium
1611 Minimum One Bit Operations to Make Integers Zero C++ Python O(logn) O(1) Hard variant of Gray Code
1641 Count Sorted Vowel Strings C++ Python O(1) O(1) Medium Binomial Coefficients
1643 Kth Smallest Instructions C++ Python O((m + n)^2) O(1) Hard Binomial Coefficients
1735 Count Ways to Make Array With Product C++ Python O(sqrt(m) + n + q * (logm + sqrt(m)/log(sqrt(m)))) O(sqrt(m) + n + logm) Hard Linear Sieve of Eratosthenes, Factorization, Combinatorics
1739 Building Boxes C++ Python O(1) O(1) Hard
1744 Can You Eat Your Favorite Candy on Your Favorite Day? C++ Python O(n) O(n) Medium Prefix Sum
1753 Maximum Score From Removing Stones C++ Python O(1) O(1) Medium
1776 Car Fleet II C++ Python O(n) O(n) Hard Mono Stack
1780 Check if Number is a Sum of Powers of Three C++ Python O(logn) O(1) Medium
1806 Minimum Number of Operations to Reinitialize a Permutation C++ Python O(sqrt(n)) O(sqrt(n)) Medium Discrete Logarithm, Multiplicative Order
1808 Maximize Number of Nice Divisors C++ Python O(logn) O(1) Medium variant of Integer Break
1812 Determine Color of a Chessboard Square C++ Python O(1) O(1) Easy
1819 Number of Different Subsequences GCDs C++ Python O(n + mlogm) O(n) Hard
1822 Sign of the Product of an Array C++ Python O(n) O(1) Easy
1823 Find the Winner of the Circular Game C++ Python O(n) O(1) Medium
1828 Queries on Number of Points Inside a Circle C++ Python O(q * n) O(1) Medium
1830 Minimum Number of Operations to Make String Sorted C++ Python O(n) O(max_n) Hard Modular Inverse
1835 Find XOR Sum of All Pairs Bitwise AND C++ Python O(n) O(1) Hard
1837 Sum of Digits in Base K C++ Python O(logn) O(1) Easy
1860 Incremental Memory Leak C++ Python O(1) O(1) Medium GCJ2020 - Round 2
1862 Sum of Floored Pairs C++ Python O(nlogn) O(n) Hard
1863 Sum of All Subset XOR Totals C++ Python O(n) O(1) Easy
1884 Egg Drop With 2 Eggs and N Floors C++ Python O(1) O(1) Medium DP
1904 The Number of Full Rounds You Have Played C++ Python O(1) O(1) Medium
1916 Count Ways to Build Rooms in an Ant Colony C++ Python O(n) O(n) Hard DFS, Tree
1922 Count Good Numbers C++ Python O(logn) O(1) Medium
1945 Sum of Digits of String After Convert C++ Python O(n) O(1) Easy
1952 Three Divisors C++ Python O(sqrt(n)) O(1) Easy
1954 Minimum Garden Perimeter to Collect Enough Apples C++ Python O(1) O(1) Medium Binary Search, Cardano's Formula
1969 Minimum Non-Zero Product of the Array Elements C++ Python O(min(p, logM)) O(1) Medium
1979 Find Greatest Common Divisor of Array C++ Python O(n) O(1) Easy
1980 Find Unique Binary String C++ Python O(n) O(1) Medium Cantor Diagonalization
1982 Find Array Given Subset Sums C++ Python O(n * 2^n) O(1) Hard Math, DP, OrderedDict
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


Sort

# Title Solution Time Space Difficulty Tag Note
1054 Distant Barcodes C++ Python O(n) O(k) Medium variant of Rearrange String k Distance Apart
1086 High Five C++ Python O(nlogn) O(n) Easy πŸ”’
1094 Car Pooling C++ Python O(nlogn) O(n) Medium variant of Meeting Rooms II
1122 Relative Sort Array C++ Python O(nlogn) O(n) Easy
1229 Meeting Scheduler C++ Python O(nlogn) O(n) Medium Line Sweep, Heap
1356 Sort Integers by The Number of 1 Bits C++ Python O(nlogn) O(1) Easy Bit Manipulation
1365 How Many Numbers Are Smaller Than the Current Number C++ Python O(n + m) O(m) Easy Counting Sort
1366 Rank Teams by Votes C++ Python O(m * (n + mlogm)) O(m^2) Medium
1451 Rearrange Words in a Sentence C++ Python O(nlogn) O(n) Medium String
1481 Least Number of Unique Integers after K Removals C++ Python O(n) O(n) Medium Counting Sort
1509 Minimum Difference Between Largest and Smallest Value in Three Moves C++ Python O(n + klogk) O(1) Medium Quick Select
1523 Count Odd Numbers in an Interval Range C++ Python O(1) O(1) Easy
1561 Maximum Number of Coins You Can Get C++ Python O(nlogn) O(1) Medium
1588 Sum of All Odd Length Subarrays C++ Python O(n) O(1) Easy
1608 Special Array With X Elements Greater Than or Equal X C++ Python O(n) O(1) Easy variant of H-Index Counting Sort, Binary Search
1620 Coordinate With Maximum Network Quality C++ Python O(n^2) O(1) Medium
1621 Number of Sets of K Non-Overlapping Line Segments C++ Python O(1) O(n) Medium Binomial Coefficients, Euler's Theorem
1630 Arithmetic Subarrays C++ Python O(n * q) O(n) Medium Arithmetic Series
1636 Sort Array by Increasing Frequency C++ Python O(nlogn) O(n) Easy
1637 Widest Vertical Area Between Two Points Containing No Points C++ Python O(nlogn) O(n) Medium
1680 Concatenation of Consecutive Binary Numbers C++ Python O(n) O(1) Medium
1685 Sum of Absolute Differences in a Sorted Array C++ Python O(n) O(1) Medium
1688 Count of Matches in Tournament C++ Python O(1) O(1) Easy
1703 Minimum Adjacent Swaps for K Consecutive Ones C++ Python O(n) O(n) Hard Math, Median, Prefix Sum
1716 Calculate Money in Leetcode Bank C++ Python O(1) O(1) Easy Arithmetic Sequence
1772 Sort Features by Popularity C++ Python O(n) O(1) Medium πŸ”’
1847 Closest Room C++ Python O(nlogn + klogk + klogn) O(n + k) Hard Sort, Binary Search
1851 Minimum Interval to Include Each Query C++ Python O(nlogn + klogk + klogn) O(n + k) Hard Sort, Heap, Line Sweep
1859 Sorting the Sentence C++ Python O(n) O(n) Easy Sort, String
1942 The Number of the Smallest Unoccupied Chair C++ Python O(nlogn) O(n) Medium Line Sweep, Heap
1943 Describe the Painting C++ Python O(nlogn) O(n) Medium Line Sweep
1968 Array With Elements Not Equal to Average of Neighbors C++ Python O(n) on average O(1) Medium variant of Wiggle Sort II Quick Select, Tri Partition
1985 Find the Kth Largest Integer in the Array C++ Python O(n) on average O(n) Medium Quick Select
1996 The Number of Weak Characters in the Game C++ Python O(nlogn) O(1) Medium
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


Two Pointers

# Title Solution Time Space Difficulty Tag Note
1004 Max Consecutive Ones III C++ Python O(n) O(1) Medium Sliding Window
1033 Moving Stones Until Consecutive C++ Python O(1) O(1) Easy
1040 Moving Stones Until Consecutive II C++ Python O(nlogn) O(1) Medium
1151 Minimum Swaps to Group All 1's Together C++ Python O(n) O(1) Medium πŸ”’ Sliding Window
1156 Swap For Longest Repeated Character Substring C++ Python O(n) O(1) Medium Sliding Window
1176 Diet Plan Performance C++ Python O(n) O(1) Easy Sliding Window
1208 Get Equal Substrings Within Budget C++ Python O(n) O(1) Medium Sliding Window
1213 Intersection of Three Sorted Arrays C++ Python O(n) O(1) Easy πŸ”’
1169 Invalid Transactions C++ Python O(nlogn) O(n) Medium Sliding Window, Line Sweep
1214 Two Sum BSTs C++ Python O(n) O(n) Medium πŸ”’ Stack
1234 Replace the Substring for Balanced String C++ Python O(n) O(t) Medium Two Pointers, Sliding Window
1248 Count Number of Nice Subarrays C++ Python O(n) O(k) Medium variant of Subarrays with K Different Integers Two Pointers, Sliding Window
1297 Maximum Number of Occurrences of a Substring C++ Python O(n) O(n) Medium Sliding Window, Rabin-Karp Algorithm
1305 All Elements in Two Binary Search Trees C++ Python O(n) O(h) Medium Stack
1316 Distinct Echo Substrings C++ Python O(n^2 + d) O(r) Hard KMP Algorithm, Sliding Window, Rabin-Karp Algorithm
1358 Number of Substrings Containing All Three Characters C++ Python O(n) O(1) Medium Sliding Window
1423 Maximum Points You Can Obtain from Cards C++ Python O(n) O(1) Medium Sliding Window
1425 Constrained Subset Sum C++ Python O(n) O(k) Hard variant of Sliding Window Maximum Mono Deque, Sliding Window
1456 Maximum Number of Vowels in a Substring of Given Length C++ Python O(n) O(1) Medium Sliding Window
1493 Longest Subarray of 1's After Deleting One Element C++ Python O(n) O(1) Medium Sliding Window
1498 Number of Subsequences That Satisfy the Given Sum Condition C++ Python O(nlogn) O(n) Medium Two Pointers
1508 Range Sum of Sorted Subarray Sums C++ Python O(nlog(sum(nums))) O(n) Medium Binary Search, Two Pointers, Sliding Window
1521 Find a Value of a Mysterious Function Closest to Target C++ Python O(nlogm) O(logm) Hard DP, Two Pointers, Sliding Window
1604 Alert Using Same Key-Card Three or More Times in a One Hour Period C++ Python O(nlogn) O(n) Medium Two Pointers, Sliding Window
1658 Minimum Operations to Reduce X to Zero C++ Python O(n) O(1) Medium Two Pointers
1687 Delivering Boxes from Storage to Ports C++ Python O(nlogn) O(n) Hard Two Pointers, Sliding Window
1695 Maximum Erasure Value C++ Python O(n) O(n) Medium Two Pointers, Sliding Window
1712 Ways to Split Array Into Three Subarrays C++ Python O(n) O(n) Medium Two Pointers, Prefix Sum
1750 Minimum Length of String After Deleting Similar Ends C++ Python O(n) O(1) Medium Two Pointers
1838 Frequency of the Most Frequent Element C++ Python O(nlogn) O(n) Medium Two Pointers, Sliding Window
1852 Distinct Numbers in Each Subarray C++ Python O(n) O(k) Medium πŸ”’ Two Pointers, Sliding Window
1855 Maximum Distance Between a Pair of Values C++ Python O(n + m) O(1) Medium Two Pointers
1868 Product of Two Run-Length Encoded Arrays C++ Python O(m + n) O(1) Medium πŸ”’ Two Pointers
1885 Count Pairs in Two Arrays C++ Python O(nlogn) O(1) Medium πŸ”’ Two Pointers
1888 Minimum Number of Flips to Make the Binary String Alternatings C++ Python O(n) O(1) Medium Two Pointers, Sliding Window
1984 Minimum Difference Between Highest and Lowest of K Scores C++ Python O(nlogn) O(1) Easy Two Pointers, Sliding Window
1989 Maximum Number of People That Can Be Caught in Tag C++ Python O(n) O(1) Medium πŸ”’ Greedy, Two Pointers, Sliding Window
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


Recursion

# Title Solution Time Space Difficulty Tag Note
1106 Parsing A Boolean Expression C++ Python O(n) O(n) Hard
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
1011 Capacity To Ship Packages Within D Days C++ Python O(nlogr) O(1) Medium
1044 Longest Duplicate Substring C++ Python O(nlogn) O(n) Hard Rabin-Karp Algorithm, Suffix Tree, Ukkonen's Algorithm
1060 Missing Element in Sorted Array C++ Python O(logn) O(1) Medium πŸ”’
1062 Longest Repeating Substring C++ Python O(nlogn) O(n) Medium πŸ”’ Rabin-Karp Algorithm
1064 Fixed Point C++ Python O(logn) O(1) Easy πŸ”’
1095 Find in Mountain Array C++ Python O(logn) O(1) Hard
1110 Delete Nodes And Return Forest C++ Python O(n) O(h + d) Medium
1170 Compare Strings by Frequency of the Smallest Character C++ Python O((m + n)logn) O(n) Easy
1201 Ugly Number III C++ Python O(logn) O(1) Medium Inclusion-Exclusion Principle
1228 Missing Number In Arithmetic Progression C++ Python O(logn) O(1) Easy
1231 Divide Chocolate C++ Python O(nlogn) O(1) Hard
1274 Number of Ships in a Rectangle C++ Python O(log(m * n)) O(log(m * n)) Hard Divide and Conquer
1283 Find the Smallest Divisor Given a Threshold C++ Python O(logn) O(1) Medium
1287 Element Appearing More Than 25% In Sorted Array C++ Python O(logn) O(1) Easy
1385 Find the Distance Value Between Two Arrays C++ Python O((n + m) * logm) O(1) Easy Binary Search, Two Pointers
1482 Minimum Number of Days to Make m Bouquets C++ Python O(nlogd) O(1) Medium
1533 Find the Index of the Large Integer C++ Python O(logn) O(1) Medium πŸ”’
1539 Kth Missing Positive Number C++ Python O(logn) O(1) Easy
1552 Magnetic Force Between Two Balls C++ Python O(nlogn + nlogr) O(1) Medium
1618 Maximum Font to Fit a Sentence in a Screen C++ Python O(n + logm) O(1) Medium πŸ”’
1648 Sell Diminishing-Valued Colored Balls C++ Python O(nlogm) O(1) Medium
1671 Minimum Number of Removals to Make Mountain Array C++ Python O(nlogn) O(n) Medium variant of Longest Increasing Subsequence Binary Search, DP
1713 Minimum Operations to Make a Subsequence C++ Python O(nlogn) O(n) Hard variant of Longest Increasing Subsequence Binary Search, Segment Tree
1760 Minimum Limit of Balls in a Bag C++ Python O(nlogm) O(1) Medium
1802 Maximum Value at a Given Index in a Bounded Array C++ Python O(logm) O(1) Medium
1818 Minimum Absolute Sum Difference C++ Python O(nlogn) O(n) Medium
1870 Minimum Speed to Arrive on Time C++ Python O(nlogr) O(1) Medium
1889 Minimum Space Wasted From Packaging C++ Python O(mlogm + nlogn + mlogn) O(1) Hard
1891 Cutting Ribbons C++ Python O(nlogr) O(1) Medium πŸ”’
1898 Maximum Number of Removable Characters C++ Python O(rlogn) O(r) Medium
1901 Find a Peak Element II C++ Python O(min(n, m) * log(max(n, m))) O(1) Medium
1918 Kth Smallest Subarray Sum C++ Python O(nlogr) O(1) Medium πŸ”’
1964 Find the Longest Valid Obstacle Course at Each Position C++ Python O(nlogn) O(n) Hard variant of Longest Increasing Subsequence Binary Search, Segment Tree, DP
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


Binary Search Tree

# Title Solution Time Space Difficulty Tag Note
1373 Maximum Sum BST in Binary Tree C++ Python O(n) O(h) Hard DFS, Stack
1382 Balance a Binary Search Tree C++ Python O(n) O(h) Medium DFS, Stack
1902 Depth of BST Given Insertion Order C++ Python O(nlogn) O(n) Medium πŸ”’ Sorted Dict
1932 Merge BSTs to Create Single BST C++ Python O(n) O(n) Hard BST, BFS
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


Breadth-First Search

# Title Solution Time Space Difficulty Tag Note
1034 Coloring A Border C++ Python O(m * n) O(m + n) Medium
1036 Escape a Large Maze C++ Python O(n^2) O(n) Hard
1091 Shortest Path in Binary Matrix C++ Python O(n^2) O(n) Medium
1102 Path With Maximum Minimum Value C++ Python O((m * n) * log(m * n)) O(m * n) Medium πŸ”’ Binary Search, DFS, Dijkstra's Algorithm
1129 Shortest Path with Alternating Colors C++ Python O(n + e) O(n + e) Medium
1136 Parallel Courses C++ Python O(|V| + |E|) O(|E|) Hard πŸ”’ Topological Sort
1161 Maximum Level Sum of a Binary Tree C++ Python O(n) O(w) Medium DFS
1162 As Far from Land as Possible C++ Python O(m * n) O(m * n) Medium
1203 Sort Items by Groups Respecting Dependencies C++ Python O(n + e) O(n + e) Hard Topological Sort
1210 Minimum Moves to Reach Target with Rotations C++ Python O(n) O(n) Hard
1215 Stepping Numbers C++ Python O(logk + r) O(k) Medium πŸ”’ Precompute, Binary Search
1245 Tree Diameter C++ Python O(|V| + |E|) O(|E|) Medium
1263 Minimum Moves to Move a Box to Their Target Location C++ Python O(m^2 * n^2) O(m^2 * n^2) Hard A* Search Algorithm
1284 Minimum Number of Flips to Convert Binary Matrix to Zero Matrix C++ Python O((m * n) * 2^(m * n)) O((m * n) * 2^(m * n)) Hard
1291 Sequential Digits C++ Python O(1) O(1) Medium
1293 Shortest Path in a Grid with Obstacles Elimination C++ Python O(m * n * k) O(m * n) Hard A* Search Algorithm
1298 Maximum Candies You Can Get from Boxes C++ Python O(n^2) O(n) Hard
1302 Deepest Leaves Sum C++ Python O(n) O(w) Medium
1306 Jump Game III C++ Python O(n) O(n) Medium
1311 Get Watched Videos by Your Friends C++ Python O(n + vlogv) O(w) Medium
1345 Jump Game IV C++ Python O(n) O(n) Hard
1368 Minimum Cost to Make at Least One Valid Path in a Grid C++ Python O(m * n) O(m * n) Hard A* Search Algorithm, 0-1 BFS, Deque
1514 Path with Maximum Probability C++ Python O(|E| * log|V|) O(|E|) Medium Dijkstra's Algorithm
1602 Find Nearest Right Node in Binary Tree C++ Python O(n) O(w) Medium πŸ”’
1609 Even Odd Tree C++ Python O(n) O(w) Medium
1625 Lexicographically Smallest String After Applying Operations C++ Python O(n^2) O(1) Medium BFS, String
1654 Minimum Jumps to Reach Home C++ Python O(max(x, max(forbidden)) + a + b) O(max(x, max(forbidden)) + a + b) Medium BFS
1660 Correct a Binary Tree C++ Python O(n) O(w) Medium πŸ”’ BFS
1728 Cat and Mouse II C++ Python O((m * n)^2 * (m + n)) O((m * n)^2) Hard variant of Cat and Mouse MiniMax, Topological Sort
1730 Shortest Path to Get Food C++ Python O(m * n) O(m + n) Medium πŸ”’ BFS
1765 Map of Highest Peak C++ Python O(m * n) O(m * n) Medium BFS
1926 Nearest Exit from Entrance in Maze C++ Python O(m * n) O(m + n) Medium Bi-BFS
1928 Minimum Cost to Reach Destination in Time C++ Python O(|E| * log|V|) O(|E|) Hard variant of Cheapest Flights Within K Stops Dijkstra's Algorithm
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


Depth-First Search

# Title Solution Time Space Difficulty Tag Note
1020 Number of Enclaves C++ Python O(m * n) O(m * n) Medium
1059 All Paths from Source Lead to Destination C++ Python O(n + e) O(n + e) Medium πŸ”’
1192 Critical Connections in a Network C++ Python O(|V| + |E|) O(|V| + |E|) Hard Tarjan's Algorithm, Bridge Finding Algorithm
1202 Smallest String With Swaps C++ Python O(nlogn) O(n) Medium Union Find
1254 Number of Closed Islands C++ Python O(m * n) O(1) Medium
1273 Delete Tree Nodes C++ Python O(n) O(n) Medium DFS, DP
1315 Sum of Nodes with Even-Valued Grandparent C++ Python O(n) O(h) Medium
1319 Number of Operations to Make Network Connected C++ Python O(|E| + |V|) O(|V|) Medium Union Find
1367 Linked List in Binary Tree C++ Python O(n + l) O(h + l) Medium KMP Algorithm
1372 Longest ZigZag Path in a Binary Tree C++ Python O(n) O(h) Medium
1376 Time Needed to Inform All Employees C++ Python O(n) O(n) Medium
1377 Frog Position After T Seconds C++ Python O(n) O(n) Hard DFS, Stack, BFS
1391 Check if There is a Valid Path in a Grid C++ Python O(m * n) O(1) Medium Simulation
1466 Reorder Routes to Make All Paths Lead to the City Zero C++ Python O(n) O(n) Medium DFS, Stack
1485 Clone Binary Tree With Random Pointer C++ Python O(n) O(h) Medium πŸ”’ DFS, Stack
1644 Lowest Common Ancestor of a Binary Tree II C++ Python O(n) O(h) Medium πŸ”’ DFS, Stack
1676 Lowest Common Ancestor of a Binary Tree IV C++ Python O(n) O(h) Medium πŸ”’ DFS, Stack
1722 Minimize Hamming Distance After Swap Operations C++ Python O(n) O(n) Medium Flood Fill, Union Find
1740 Find Distance in a Binary Tree C++ Python O(n) O(h) Medium variant of Lowest Common Ancestor of a Binary Tree, πŸ”’
1766 Tree of Coprimes C++ Python O(n) O(n) Hard
1905 Count Sub Islands C++ Python O(m * n) O(1) Medium Flood Fill
1973 Count Nodes Equal to Sum of Descendants C++ Python O(n) O(h) Medium πŸ”’
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


Backtracking

# Title Solution Time Space Difficulty Tag Note
1087 Brace Expansion C++ Python O(p * l * log(p * l)) O(p * l) Medium πŸ”’
1096 Brace Expansion II C++ Python O(p * l * log(p * l)) O(p * l) Hard
1219 Path with Maximum Gold C++ Python O(m^2 * n^2) O(m * n) Medium
1240 Tiling a Rectangle with the Fewest Squares C++ Python O(n^2 * m^2 * m^(n * m)) O(n * m) Hard
1255 Maximum Score Words Formed by Letters C++ Python O(n * 2^n) O(n) Hard
1258 Synonymous Sentences C++ Python O(p * l * log(p * l)) O(p * l) Medium Union Find
1307 Verbal Arithmetic Puzzle C++ Python O(10! * n * l) O(n * l) Hard
1379 Find a Corresponding Node of a Binary Tree in a Clone of That Tree C++ Python O(n) O(h) Medium Stack
1593 Split a String Into the Max Number of Unique Substrings C++ Python O(n * 2^(n - 1)) O(n) Medium
1659 Maximize Grid Happiness C++ Python O(C(m * n, i) * C(m * n - i, e)) O(min(m * n, i + e)) Hard Pruning
1718 Construct the Lexicographically Largest Valid Sequence C++ Python O(n!) O(b) Medium Backtracking
1723 Find Minimum Time to Finish All Jobs C++ Python O(k^n * logr) O(n + k) Hard Backtracking, Pruning, Binary Search
1849 Splitting a String Into Descending Consecutive Values C++ Python O(n^2) O(n) Medium
1999 Smallest Greater Multiple Made of Two Digits C++ Python O(1) O(1) Medium πŸ”’ Backtracking, Bit Manipulation
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


Dynamic Programming

# Title Solution Time Space Difficulty Tag Note
1027 Longest Arithmetic Sequence C++ Python O(n^2) O(n^2) Medium
1035 Uncrossed Lines C++ Python O(m * n) O(min(m, n)) Medium
1039 Minimum Score Triangulation of Polygon C++ Python O(n^3) O(n^2) Medium
1043 Partition Array for Maximum Sum C++ Python O(n * k) O(k) Medium
1048 Longest String Chain C++ Python O(n * l^2) O(n * l) Medium
1049 Last Stone Weight II C++ Python O(2^n) O(2^n) Medium
1066 Campus Bikes II C++ Python O(w * b * 2^b) O(w * b * 2^b) Medium πŸ”’
1092 Shortest Common Supersequence C++ Python O(m * n) O(m * n) Hard
1105 Filling Bookcase Shelves C++ Python O(n^2) O(n) Medium
1125 Smallest Sufficient Team C++ Python O(m * 2^n) O(2^n) Hard
1137 N-th Tribonacci Number C++ Python O(logn) O(1) Easy variant of Fibonacci Number Matrix Exponentiation
1139 Largest 1-Bordered Square C++ Python O(n^3) O(n^2) Medium
1140 Stone Game II C++ Python O(n*(logn)^2) O(nlogn) Medium
1143 Longest Common Subsequence C++ Python O(m * n) O(min(m, n)) Medium
1155 Number of Dice Rolls With Target Sum C++ Python O(d * f * t) O(t) Medium
1182 Shortest Distance to Target Color C++ Python O(n) O(n) Medium πŸ”’
1186 Maximum Subarray Sum with One Deletion C++ Python O(n) O(1) Medium
1187 Make Array Strictly Increasing C++ Python O(n^2 * logn) O(n) Hard
1191 K-Concatenation Maximum Sum C++ Python O(n) O(1) Medium
1216 Valid Palindrome III C++ Python O(n^2) O(n) Hard πŸ”’, variant of Longest Palindromic Subsequence
1218 Longest Arithmetic Subsequence of Given Difference C++ Python O(n) O(n) Medium
1220 Count Vowels Permutation C++ Python O(logn) O(1) Hard Matrix Exponentiation
1223 Dice Roll Simulation C++ Python O(m * n) O(m) Medium
1230 Toss Strange Coins C++ Python O(n^2) O(n) Medium
1235 Maximum Profit in Job Scheduling C++ Python O(nlogn) O(n) Hard DP, Heap
1239 Maximum Length of a Concatenated String with Unique Characters C++ Python O(n) ~ O(2^n) O(1) ~ O(2^n) Medium DP, Bit Manipulation
1246 Palindrome Removal C++ Python O(n^3) O(n^2) Hard
1262 Greatest Sum Divisible by Three C++ Python O(n) O(1) Medium
1269 Number of Ways to Stay in the Same Place After Some Steps C++ Python O(n^2) O(n) Hard
1277 Count Square Submatrices with All Ones C++ Python O(m * n) O(1) Medium
1278 Palindrome Partitioning III C++ Python O(k * n^2) O(n^2) Hard
1289 Minimum Falling Path Sum II C++ Python O(m * n) O(1) Hard
1292 Maximum Side Length of a Square with Sum Less than or Equal to Threshold C++ Python O(m * n * log(min(m, n))) O(m * n) Medium Binary Search
1301 Number of Paths with Max Score C++ Python O(n^2) O(n) Hard
1312 Minimum Insertion Steps to Make a String Palindrome C++ Python O(n^2) O(n) Hard variant of Longest Common Subsequence
1314 Matrix Block Sum C++ Python O(m * n) O(m * n) Medium variant of Range Sum Query 2D - Immutable
1320 Minimum Distance to Type a Word Using Two Fingers C++ Python O(n) O(1) Hard
1335 Minimum Difficulty of a Job Schedule C++ Python O(d * n^2) O(d * n) Hard
1340 Jump Game V C++ Python O(n) O(n) Hard Sliding Window, Mono Stack, Segment Tree
1387 Sort Integers by The Power Value C++ Python O(n) on average O(n) Medium Quick Select
1388 Pizza With 3n Slices C++ Python O(n^2) O(n) Hard variant of House Robber II
1395 Count Number of Teams C++ Python O(n^2) O(1) Medium
1397 Find All Good Strings C++ Python O(m * n) O(m) Hard KMP Algorithm
1406 Stone Game III C++ Python O(n) O(1) Hard
1411 Number of Ways to Paint N Γ— 3 Grid C++ Python O(logn) O(1) Hard Matrix Exponentiation
1416 Restore The Array C++ Python O(nlogk) O(logk) Hard
1420 Build Array Where You Can Find The Maximum Exactly K Comparisons C++ Python O(n * m * k) O(m * k) Hard
1434 Number of Ways to Wear Different Hats to Each Other C++ Python O(h * 2^n) O(2^n) Hard
1444 Number of Ways of Cutting a Pizza C++ Python O(m * n * k * (m + n)) O(m * n * k) Hard
1449 Form Largest Integer With Digits That Add up to Target C++ Python O(t) O(t) Hard
1458 Max Dot Product of Two Subsequences C++ Python O(m * n) O(min(m, n)) Hard
1463 Cherry Pickup II C++ Python O(m * n^2) O(n^2) Hard
1467 Probability of a Two Boxes Having The Same Number of Distinct Balls C++ Python O(k^3 * n^2) O(k^2 * n) Hard Binomial Coefficients
1473 Paint House III C++ Python O(m * t * n^2) O(t * n) Hard
1477 Find Two Non-overlapping Sub-arrays Each With Target Sum C++ Python O(n) O(n) Medium
1478 Allocate Mailboxes C++ Python O(m * n^2) O(n) Hard DP, Math, Median
1494 Parallel Courses II C++ Python O((n * C(c, min(c, k))) * 2^n) O(2^n) Hard Combinations
1504 Count Submatrices With All Ones C++ Python O(m * n) O(n) Medium Mono Stack
1510 Stone Game IV C++ Python O(n * sqrt(n)) O(n) Hard
1524 Number of Sub-arrays With Odd Sum C++ Python O(n) O(1) Medium
1531 String Compression II C++ Python O(n^2 * k) O(n * k) Hard
1547 Minimum Cost to Cut a Stick C++ Python O(n^3) O(n^2) Hard
1548 The Most Similar Path in a Graph C++ Python O(n^ * m) O(n * m) Hard πŸ”’
1553 Minimum Number of Days to Eat N Oranges C++ Python O((logn)^2) O((logn)^2) Hard
1563 Stone Game V C++ Python O(n^2) O(n^2) Hard
1569 Number of Ways to Reorder Array to Get Same BST C++ Python O(n^2) O(n^2) Hard DFS
1575 Count All Possible Routes C++ Python O(nlogn + n * f) O(n * f) Hard Math
1594 Maximum Non Negative Product in a Matrix C++ Python O(m * n) O(n) Medium
1595 Minimum Cost to Connect Two Groups of Points C++ Python O(m * n * 2^n) O(2^n) Hard
1617 Count Subtrees With Max Distance Between Cities C++ Python O(n^6) O(n^3) Hard Backtracking, Graph
1626 Best Team With No Conflicts C++ Python O(nloga) O(n) Medium variant of Longest Increasing Subsequence Sort, DP, Segment Tree
1639 Number of Ways to Form a Target String Given a Dictionary C++ Python O(l * (w + n)) O(n) Hard
1655 Distribute Repeating Integers C++ Python O(n + m * 3^m) O(n + 2^m) Hard Submask Enumeration
1664 Ways to Make a Fair Array C++ Python O(n) O(1) Medium Prefix Sum
1681 Minimum Incompatibility C++ Python O(max(n * 2^n, 3^n)) O(2^n) Hard Combinations, Backtracking, Submask Enumeration
1682 Longest Palindromic Subsequence II C++ Python O(n^2) O(n) Medium πŸ”’
1690 Stone Game VII C++ Python O(n^2) O(n) Medium
1691 Maximum Height by Stacking Cuboids C++ Python O(n^2) O(n) Hard
1692 Count Ways to Distribute Candies C++ Python O(n * k) O(k) Hard πŸ”’
1745 Palindrome Partitioning IV C++ Python O(n^2) O(n) Hard DP, Manacher's Algorithm
1746 Maximum Subarray Sum After One Operation C++ Python O(n) O(1) Medium variant of Maximum Subarray, πŸ”’
1751 Maximum Number of Events That Can Be Attended II C++ Python O(nlogn + n * k) O(n * k) Hard Binary Search
1770 Maximum Score from Performing Multiplication Operations C++ Python O(m^2) O(m) Medium
1771 Maximize Palindrome Length From Subsequences C++ Python O((m + n)^2) O((m + n)^2) Hard
1774 Closest Dessert Cost C++ Python O(m * t) O(t) Medium
1787 Make the XOR of All Segments Equal to Zero C++ Python O(n + k * m) O(min(k * m, n)) Hard
1799 Maximize Score After N Operations C++ Python O(n^2 * 2^n) O(2^n) Hard
1803 Count Pairs With XOR in a Range C++ Python O(n) O(n) Hard DP, Trie
1857 Largest Color Value in a Directed Graph C++ Python O(n + m) O(n + m) Hard DP, Topological Sort
1866 Number of Ways to Rearrange Sticks With K Sticks Visible C++ Python O(n * k) O(k) Hard
1871 Jump Game VII C++ Python O(n) O(n) Medium Line Sweep, DP, BFS
1872 Stone Game VIII C++ Python O(n) O(1) Hard
1883 Minimum Skips to Arrive at Meeting On Time C++ Python O(n^2) O(n) Hard
1896 Minimum Cost to Change the Final Value of Expression C++ Python O(n) O(n) Hard Stack, DP
1900 The Earliest and Latest Rounds Where Players Compete C++ Python O(n^4) O(n^2) Hard
1908 Game of Nim C++ Python O(n) O(1) Medium πŸ”’
1931 Painting a Grid With Three Different Colors C++ Python O(2^(3 * m) * logn) O(2^(2 * m)) Hard variant of Number of Ways to Paint N Γ— 3 Grid DP, Backtracking, Matrix Exponentiation, State Compression
1937 Maximum Number of Points with Cost C++ Python O(m * n) O(n) Medium Prefix Sum
1955 Count Number of Special Subsequences C++ Python O(n) O(1) Hard
1959 Minimum Total Space Wasted With K Resizing Operations C++ Python O(k * n^2) O(k * n) Medium
1960 Maximum Product of the Length of Two Palindromic Substrings C++ Python O(n) O(n) Hard Manacher's Algorithm, DP
1977 Number of Ways to Separate Numbers C++ Python O(n^2) O(n^2) Hard DP
1981 Minimize the Difference Between Target and Chosen Elements C++ Python O(t * m * n) O(t) Medium DP, Pruning
1986 Minimum Number of Work Sessions to Finish the Tasks C++ Python O(n * 2^n) O(2^n) Medium DP
1987 Number of Unique Good Subsequences C++ Python O(n) O(1) Hard variant of Distinct Subsequences II DP
1994 The Number of Good Subsets C++ Python O(n * 2^p) O(2^p) Hard DP, Sieve of Eratosthenes
1997 First Day Where You Have Been in All the Rooms C++ Python O(n) O(n) Medium DP
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


Greedy

# Title Solution Time Space Difficulty Tag Note
1005 Maximize Sum Of Array After K Negations C++ Python O(n) on average O(1) Easy Quick Select
1024 Video Stitching C++ Python O(nlogn) O(1) Medium variant of Jump Game II
1029 Two City Scheduling C++ Python O(n) on average O(1) Easy Quick Select
1053 Previous Permutation With One Swap C++ Python O(n) O(1) Medium
1055 Shortest Way to Form String C++ Python O(m + n) O(m) Medium πŸ”’, variant of Minimum Window Subsequence
1058 Minimize Rounding Error to Meet Target C++ Python O(n) on average O(n) Medium πŸ”’ Quick Select
1081 Smallest Subsequence of Distinct Characters C++ Python O(n) O(1) Medium same as Remove Duplicate Letters Mono Stack
1090 Largest Values From Labels C++ Python O(nlogn) O(n) Medium
1111 Maximum Nesting Depth of Two Valid Parentheses Strings C++ Python O(n) O(1) Medium
1163 Last Substring in Lexicographical Order C++ Python O(n) O(1) Hard
1167 Minimum Cost to Connect Sticks C++ Python O(nlogn) O(n) Medium πŸ”’
1183 Maximum Number of Ones C++ Python O(1) O(1) Hard πŸ”’
1196 How Many Apples Can You Put into the Basket C++ Python O(nlogn) O(n) Easy πŸ”’
1199 Minimum Time to Build Blocks C++ Python O(nlogn) O(n) Hard πŸ”’
1221 Split a String in Balanced Strings C++ Python O(n) O(1) Easy
1247 Minimum Swaps to Make Strings Equal C++ Python O(n) O(1) Easy
1249 Minimum Remove to Make Valid Parentheses C++ Python O(n) O(1) Medium Stack
1253 Reconstruct a 2-Row Binary Matrix C++ Python O(n) O(1) Medium
1272 Remove Interval C++ Python O(n) O(1) Medium Line Sweep
1282 Group the People Given the Group Size They Belong To C++ Python O(n) O(n) Medium
1288 Remove Covered Intervals C++ Python O(nlogn) O(1) Medium Line Sweep
1296 Divide Array in Sets of K Consecutive Numbers C++ Python O(nlogn) O(n) Medium
1326 Minimum Number of Taps to Open to Water a Garden C++ Python O(n) O(n) Hard variant of Jump Game II
1338 Reduce Array Size to The Half C++ Python O(n) O(n) Medium Counting Sort
1353 Maximum Number of Events That Can Be Attended C++ Python O(r + nlogn) O(n) Medium Heap, Sort
1354 Construct Target Array With Multiple Sums C++ Python O(log(max(t)) * logn) O(n) Hard Heap
1383 Maximum Performance of a Team C++ Python O(nlogn) O(n) Hard variant of Minimum Cost to Hire K Workers Greedy, Heap
1386 Cinema Seat Allocation C++ Python O(n) O(n) Medium
1400 Construct K Palindrome Strings C++ Python O(n) O(1) Medium
1402 Reducing Dishes C++ Python O(nlogn) O(1) Hard
1403 Minimum Subsequence in Non-Increasing Order C++ Python O(nlogn) O(1) Easy
1405 Longest Happy String C++ Python O(n) O(1) Medium
1414 Find the Minimum Number of Fibonacci Numbers Whose Sum Is K C++ Python O(logk) O(1) Medium
1419 Minimum Number of Frogs Croaking C++ Python O(n) O(1) Medium
1433 Check If a String Can Break Another String C++ Python O(n) O(1) Medium
1488 Avoid Flood in The City C++ Python O(nlogn) O(n) Medium
1518 Water Bottles C++ Python O(logn/logm) O(1) Easy
1520 Maximum Number of Non-Overlapping Substrings C++ Python O(n) O(1) Medium
1526 Minimum Number of Increments on Subarrays to Form a Target Array C++ Python O(n) O(1) Hard
1536 Minimum Swaps to Arrange a Binary Grid C++ Python O(n^2) O(1) Medium
1546 Maximum Number of Non-Overlapping Subarrays With Sum Equals Target C++ Python O(n) O(n) Medium
1564 Put Boxes Into the Warehouse I C++ Python O(nlogn) O(1) Medium πŸ”’
1567 Maximum Length of Subarray With Positive Product C++ Python O(n) O(1) Medium
1568 Minimum Number of Days to Disconnect Island C++ Python O(m^2 * n^2) O(m * n) Medium DFS
1578 Minimum Deletion Cost to Avoid Repeating Letters C++ Python O(n) O(1) Medium
1580 Put Boxes Into the Warehouse II C++ Python O(nlogn) O(1) Medium πŸ”’
1585 Check If String Is Transformable With Substring Sort Operations C++ Python O(n) O(n) Hard
1589 Maximum Sum Obtained of Any Permutation C++ Python O(nlogn) O(n) Medium
1591 Strange Printer II C++ Python O(c * m * n + e) O(e) Hard
1599 Maximum Profit of Operating a Centennial Wheel C++ Python O(n) O(1) Medium
1605 Find Valid Matrix Given Row and Column Sums C++ Python O(m + n) O(1) Medium
1616 Split Two Strings to Make Palindrome C++ Python O(n) O(1) Medium Two Pointers
1632 Rank Transform of a Matrix C++ Python O(m * n * log(m * n)) O(m * n) Hard Union Find
1647 Minimum Deletions to Make Character Frequencies Unique C++ Python O(n) O(1) Medium
1653 Minimum Deletions to Make String Balanced C++ Python O(n) O(1) Medium
1663 Smallest String With A Given Numeric Value C++ Python O(n) O(1) Medium
1665 Minimum Initial Energy to Finish Tasks C++ Python O(nlogn) O(1) Hard
1673 Find the Most Competitive Subsequence C++ Python O(n) O(k) Meidum Stack, Greedy
1674 Minimum Moves to Make Array Complementary C++ Python O(n + k) O(k) Meidum
1686 Stone Game VI C++ Python O(nlogn) O(n) Medium
1689 Partitioning Into Minimum Number Of Deci-Binary Numbers C++ Python O(n) O(1) Medium
1702 Maximum Binary String After Change C++ Python O(n) O(1) Medium
1705 Maximum Number of Eaten Apples C++ Python O(nlogn) O(n) Medium Heap
1708 Largest Subarray Length K C++ Python O(n) O(1) Easy πŸ”’, variant of Last Substring in Lexicographical Order
1710 Maximum Units on a Truck C++ Python O(nlogn) O(1) Easy
1717 Maximum Score From Removing Substrings C++ Python O(n) O(1) Medium
1725 Number Of Rectangles That Can Form The Largest Square C++ Python O(n) O(1) Easy
1727 Largest Submatrix With Rearrangements C++ Python O(m * nlogn) O(1) Medium Sort
1733 Minimum Number of People to Teach C++ Python O(n * m^2) O(n * m) Medium
1736 Latest Time by Replacing Hidden Digits C++ Python O(1) O(1) Easy
1737 Change Minimum Characters to Satisfy One of Three Conditions C++ Python O(m + n) O(1) Medium Prefix Sum
1749 Maximum Absolute Sum of Any Subarray C++ Python O(n) O(1) Medium variant of Maximum Subarray Prefix Sum
1754 Largest Merge Of Two Strings C++ Python O(m * n) O(m + n) Medium
1758 Minimum Changes To Make Alternating Binary String C++ Python O(n) O(1) Easy
1759 Count Number of Homogenous Substrings C++ Python O(n) O(1) Medium
1762 Buildings With an Ocean View C++ Python O(n) O(1) Medium πŸ”’
1764 Form Array by Concatenating Subarrays of Another Array C++ Python O(n) O(n) Medium KMP Algorithm
1769 Minimum Number of Operations to Move All Balls to Each Box C++ Python O(n) O(1) Medium
1775 Equal Sum Arrays With Minimum Number of Operations C++ Python O(m + n) O(1) Medium
1785 Minimum Elements to Add to Form a Given Sum C++ Python O(n) O(1) Medium
1788 Maximize the Beauty of the Garden C++ Python O(n) O(n) Hard πŸ”’
1793 Maximum Score of a Good Subarray C++ Python O(n) O(1) Hard Greedy, Prefix Sum. Binary Search
1794 Count Pairs of Equal Substrings With Minimum Difference C++ Python O(n) O(1) Medium πŸ”’
1798 Maximum Number of Consecutive Values You Can Make C++ Python O(nlogn) O(1) Medium
1801 Number of Orders in the Backlog C++ Python O(nlogn) O(n) Medium Greedy, Heap
1815 Maximum Number of Groups Getting Fresh Donuts C++ Python O((b/2) * (n/(b/2)+1)^(b/2)) O((n/(b/2)+1)^(b/2)) Hard Greedy, DP
1824 Minimum Sideway Jumps C++ Python O(n) O(1) Medium Greedy, DP
1827 Minimum Operations to Make the Array Increasing C++ Python O(n) O(1) Easy
1833 Maximum Ice Cream Bars C++ Python O(nlogn) O(1) Medium
1840 Maximum Building Height C++ Python O(nlogn) O(1) Hard
1842 Next Palindrome Using Same Digits C++ Python O(n) O(1) Hard πŸ”’
1846 Maximum Element After Decreasing and Rearranging C++ Python O(nlogn) O(1) Medium
1850 Minimum Adjacent Swaps to Reach the Kth Smallest Number C++ Python O((k + n) * n) O(n) Medium
1864 Minimum Number of Swaps to Make the Binary String Alternating C++ Python O(n) O(1) Medium
1874 Minimize Product Sum of Two Arrays C++ Python O(nlogn) O(1) Medium GCJ2008 - Round 1A, πŸ”’
1877 Minimize Maximum Pair Sum in Array C++ Python O(nlogn) O(1) Medium
1881 Maximum Value after Insertion C++ Python O(n) O(1) Medium
1887 Reduction Operations to Make the Array Elements Equal C++ Python O(nlogn) O(1) Medium Sort
1893 Check if All the Integers in a Range Are Covered C++ Python O(n + r) O(r) Easy Line Sweep, Sort
1894 Find the Student that Will Replace the Chalk C++ Python O(n) O(1) Medium
1897 Redistribute Characters to Make All Strings Equal C++ Python O(n) O(1) Easy
1899 Merge Triplets to Form Target Triplet C++ Python O(n) O(1) Medium
1911 Maximum Alternating Subsequence Sum C++ Python O(n) O(1) Medium variant of Best Time to Buy and Sell Stock II
1913 Maximum Product Difference Between Two Pairs C++ Python O(n) O(1) Medium
1921 Eliminate Maximum Number of Monsters C++ Python O(nlogn) O(1) Medium
1927 Sum Game C++ Python O(n) O(1) Medium
1936 Add Minimum Number of Rungs C++ Python O(n) O(1) Medium
1946 Largest Number After Mutating Substring C++ Python O(n) O(1) Medium
1953 Maximum Number of Weeks for Which You Can Work C++ Python O(n) O(1) Medium
1975 Maximum Matrix Sum C++ Python O(n^2) O(1) Medium
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


Graph

# Title Solution Time Space Difficulty Tag Note
1042 Flower Planting With No Adjacent C++ Python O(n) O(n) Easy
1101 The Earliest Moment When Everyone Become Friends C++ Python O(nlogn) O(n) Medium πŸ”’ Union Find
1135 Connecting Cities With Minimum Cost C++ Python O(nlogn) O(n) Medium πŸ”’ Union Find, Kruskal's Algorithm, MST
1168 Optimize Water Distribution in a Village C++ Python O(nlogn) O(n) Hard πŸ”’ Union Find
1334 Find the City With the Smallest Number of Neighbors at a Threshold Distance C++ Python O(n^3) O(n^2) Medium Floyd-Warshall Algorithm
1349 Maximum Students Taking Exam C++ Python O(m * n * sqrt(m * n)) O(m + n) Hard GCJ2008 - Round 3 Hopcroft-Karp Bipartite Matching, Hungarian Bipartite Matching, Maximum Independent Set
1361 Validate Binary Tree Nodes C++ Python O(n) O(n) Medium DFS, Tree
1462 Course Schedule IV C++ Python O(n^3) O(n^2) Medium Floyd-Warshall Algorithm
1489 Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree C++ Python O(nlogn) O(n) Hard Kruskal Algorithm
1557 Minimum Number of Vertices to Reach All Nodes C++ Python O(e) O(n) Medium
1579 Remove Max Number of Edges to Keep Graph Fully Traversable C++ Python O(n + m) O(n) Hard Union Find
1584 Min Cost to Connect All Points C++ Python O(n^2) O(n) Medium Union Find, Kruskal's Algorithm, MST
1601 Maximum Number of Achievable Transfer Requests C++ Python O((n + r) * 2^r) O(n + r) Hard Combinations, Backtracking
1615 Maximal Network Rank C++ Python O(m + n + k^2) O(m + n) Medium Counting Sort
1627 Graph Connectivity With Threshold C++ Python O(nlogn + q) O(n) Hard Union Find, Math
1631 Path With Minimum Effort C++ Python O(m * n * log(m * n)) O(m * n) Medium Binary Search, DFS, BFS, Bi-BFS, Union Find, Dijkstra's Algorithm
1697 Checking Existence of Edge Length Limited Paths C++ Python O(nlogn + mlogm) O(n) Hard Union Find
1719 Number Of Ways To Reconstruct A Tree C++ Python O(nlogn) O(n) Hard
1724 Checking Existence of Edge Length Limited Paths II C++ Python ctor: O(nlogn + mlogm)
query: O(logn)
O(nlogn + m) Hard πŸ”’ Versioned Union Find, Binary Lifting
1743 Restore the Array From Adjacent Pairs C++ Python O(n) O(n) Medium
1761 Minimum Degree of a Connected Trio in a Graph C++ Python O(n^3) O(n^2) Hard
1778 Shortest Path in a Hidden Grid C++ Python O(m * n) O(m * n) Medium πŸ”’ DFS, BFS, Bi-BFS
1782 Count Pairs Of Nodes C++ Python O(n + e + q) O(n + e) Hard Counting, Two Pointers
1786 Number of Restricted Paths From First to Last Node C++ Python O(|E| * log|V|) O(|E|) Medium Dijkstra's Algorithm, DP
1791 Find Center of Star Graph C++ Python O(n) O(n) Medium
1810 Minimum Path Cost in a Hidden Grid C++ Python O(m * n * log(m * n)) O(m * n) Medium πŸ”’ DFS, Dijkstra's Algorithm
1820 Maximum Number of Accepted Invitations C++ Python O(m * n * sqrt(m + n)) O(m + n) Medium πŸ”’ Hopcroft-Karp Bipartite Matching, Hungarian Bipartite Matching
1879 Minimum XOR Sum of Two Arrays C++ Python O(n^3) O(n^2) Hard DP, Hungarian Weighted Bipartite Matching
1947 Maximum Compatibility Score Sum C++ Python O(m^2 * (n + m)) O(m^2) Medium variant of Minimum XOR Sum of Two Arrays DP, Hungarian Weighted Bipartite Matching
1971 Find if Path Exists in Graph C++ Python O(|V| + |E|) O(|V| + |E|) Easy DFS, BFS, Bi-BFS
1976 Number of Ways to Arrive at Destination C++ Python O(|E| * log|V|) O(|E|) Medium Dijkstra's Algorithm
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


Geometry

# Title Solution Time Space Difficulty Tag Note
1453 Maximum Number of Darts Inside of a Circular Dartboard C++ Python O(n^2 * logn) O(n) Hard Line Sweep
1515 Best Position for a Service Centre C++ Python O(n * iter) O(n) Hard Geometric Median, Gradient Descent, Weiszfeld's Algorithm
1610 Maximum Number of Visible Points C++ Python O(nlogn) O(n) Hard Two Pointers, Sliding Window
1924 Erect the Fence II C++ Python O(n) on average O(n) Hard πŸ”’ Welzl's Algorithm
1956 Minimum Time For K Virus Variants to Spread C++ Python O(nlogn * logr) O(n) Hard πŸ”’ Geometry, Binary Search, Line Sweep, Segment Tree, Coordinate Compression
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
1138 Alphabet Board Path C++ Python O(n) O(1) Medium
1243 Array Transformation C++ Python O(n^2) O(n) Easy
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


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


Design

# Title Solution Time Space Difficulty Tag Note
1146 Snapshot Array C++ Python set: O(1)
get: O(logn)
O(n) Medium
1166 Design File System C++ Python create: O(n)
get: O(n)
O(n) Medium πŸ”’
1172 Dinner Plate Stacks C++ Python push: O(logn)
pop: O(1), amortized
popAtStack: (logn)
O(n * c) Hard
1206 Design Skiplist C++ Python O(logn), on average O(n) Hard
1236 Web Crawler C++ Python O(|V| + |E|) O(|V|) Medium πŸ”’ BFS, DFS
1244 Design A Leaderboard C++ Python ctor: O(1)
add: O(1)
top: O(n)
reset: O(1)
O(n) Medium
1268 Search Suggestions System C++ Python ctor: O(n * l)
suggest: O(l^2)
O(t) Medium Trie
1286 Iterator for Combination C++ Python O(k) O(k) Medium Stack
1348 Tweet Counts Per Frequency C++ Python add: O(logn)
query: O(c)
O(n) Medium
1352 Product of the Last K Numbers C++ Python ctor: O(1)
add: O(1)
get: O(1)
O(n) Medium
1357 Apply Discount Every n Orders C++ Python ctor: O(m)
getBill: O(p)
O(m) Medium
1381 Design a Stack With Increment Operation C++ Python ctor: O(1)
push: O(1)
pop: O(1)
increment: O(1)
O(n) Medium
1396 Design Underground System C++ Python ctor: O(1)
checkin: O(1)
checkout: O(1)
getaverage: O(1)
O(n) Medium
1429 First Unique Number C++ Python ctor: O(k)
add: O(1)
showFirstUnique: O(1)
O(n) Medium πŸ”’ LinkedHashSet
1472 Design Browser History C++ Python ctor: O(1)
visit: O(1)
back: O(1)
forward: O(1)
O(n) Medium
1476 Subrectangle Queries C++ Python ctor: O(1)
update: O(1)
get: O(u)
O(u) Medium
1483 Kth Ancestor of a Tree Node C++ Python ctor: O(n * logh)
get: O(logh)
O(n * logh) Hard DP, Binary Lifting
1500 Design a File Sharing System C++ Python ctor: O(1)
join: O(logu + c)
leave: O(logu + c)
request: O(u)
O(u * c) Medium πŸ”’
1570 Dot Product of Two Sparse Vectors C++ Python ctor: O(n)
dot_product: O(min(n, m))
O(n) Medium πŸ”’
1586 Binary Search Tree Iterator II C++ Python O(1), amortized O(h) Medium πŸ”’
1600 Throne Inheritance C++ Python ctor: O(1)
birth: O(1)
death: O(1)
inherit: O(n)
O(n) Medium
1603 Design Parking System C++ Python O(1) O(1) Easy
1622 Fancy Sequence C++ Python O(1) O(n) Hard Euler's Theorem
1628 Design an Expression Tree With Evaluate Function C++ Python O(n) O(h) Medium πŸ”’
1656 Design an Ordered Stream C++ Python O(1), amortized O(n) Easy
1670 Design Front Middle Back Queue C++ Python O(1) O(n) Medium
1756 Design Most Recently Used Queue C++ Python ctor: O(nlogn)
fetch: O(logn)
O(n) Medium πŸ”’ Sorted List, BIT, Fenwick Tree, Square Root Decomposition
1797 Design Authentication Manager C++ Python ctor: O(1)
generate: O(1), amortized
renew: O(1), amortized
count: O(1), amortized
O(n) Medium OrderedDict
1804 Implement Trie II (Prefix Tree) C++ Python ctor: O(1)
insert: O(n)
count_word: O(n)
count_prefix: O(n)
erase: O(n)
O(t) Medium πŸ”’ Trie
1825 Finding MK Average C++ Python ctor: O(1)
add_element: O(logn)
calc_mkaverge: O(1)
O(m) Hard Sorted List
1845 Seat Reservation Manager C++ Python ctor: O(n)
reserve: O(logn)
unreserve: O(logn)
O(n) Medium Heap
1865 Finding Pairs With a Certain Sum C++ Python ctor: O(n1 + n2)
add: O(1)
count: O(n1)
O(n1 + n2) Medium Hash Table
1912 Design Movie Rental System C++ Python ctor: O(nlogn)
search: O(logn)
rent: O(logn)
drop: O(logn)
report: O(logn)
O(n) Hard Ordered List
1993 Operations on Tree C++ Python ctor: O(n)
lock: O(1)
unlock: O(1)
upgrade: O(n)
O(n) Medium
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


Concurrency

# Title Solution Time Space Difficulty Tag Note
1114 Print in Order C++ Python O(n) O(1) Easy
1115 Print FooBar Alternately C++ Python O(n) O(1) Medium
1116 Print Zero Even Odd C++ Python O(n) O(1) Medium
1117 Building H2O C++ Python O(n) O(1) Hard
1188 Design Bounded Blocking Queue C++ Python O(n) O(1) Medium πŸ”’
1195 Fizz Buzz Multithreaded C++ Python O(n) O(1) Medium
1226 The Dining Philosophers C++ Python O(n) O(1) Medium
1242 Web Crawler Multithreaded C++ Python O(|V| + |E|) O(|V|) Medium πŸ”’
1279 Traffic Light Controlled Intersection C++ Python O(n) O(1) Easy πŸ”’


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


SQL

# Title Solution Time Space Difficulty Tag Note
1045 Customers Who Bought All Products MySQL O(n + k) O(n + k) Medium πŸ”’
1050 Actors and Directors Who Cooperated At Least Three Times MySQL O(n) O(n) Easy πŸ”’
1068 Product Sales Analysis I MySQL O(m + n) O(m + n) Easy πŸ”’
1069 Product Sales Analysis II MySQL O(n) O(n) Easy πŸ”’
1070 Product Sales Analysis III MySQL O(n) O(n) Medium πŸ”’
1075 Project Employees I MySQL O(m + n) O(m + n) Easy πŸ”’
1076 Project Employees II MySQL O(n) O(n) Easy πŸ”’
1077 Project Employees III MySQL O((m + n)^2) O(m + n) Medium πŸ”’
1082 Sales Analysis I MySQL O(n) O(n) Easy πŸ”’
1083 Sales Analysis II MySQL O(m + n) O(m + n) Easy πŸ”’
1084 Sales Analysis III MySQL O(m + n) O(m + n) Easy πŸ”’
1097 Game Play Analysis V MySQL O(n^2) O(n) Hard πŸ”’
1098 Unpopular Books MySQL O(m + n) O(n) Medium πŸ”’
1107 New Users Daily Count MySQL O(n) O(n) Medium πŸ”’
1112 Highest Grade For Each Student MySQL O(nlogn) O(n) Medium πŸ”’
1113 Reported Posts MySQL O(n) O(n) Easy πŸ”’
1126 Active Businesses MySQL O(n) O(n) Medium πŸ”’
1127 User Purchase Platform MySQL O(n) O(n) Hard πŸ”’
1132 Reported Posts II MySQL O(m + n) O(n) Medium πŸ”’
1141 User Activity for the Past 30 Days I MySQL O(n) O(n) Easy πŸ”’
1142 User Activity for the Past 30 Days II MySQL O(n) O(n) Easy πŸ”’
1148 Article Views I MySQL O(nlogn) O(n) Easy πŸ”’
1149 Article Views II MySQL O(nlogn) O(n) Medium πŸ”’
1158 Market Analysis I MySQL O(m + n) O(m + n) Medium πŸ”’
1159 Market Analysis II MySQL O(m + n) O(m + n) Hard πŸ”’
1164 Product Price at a Given Date MySQL O(mlogn) O(m) Medium πŸ”’
1173 Immediate Food Delivery I MySQL O(n) O(1) Easy πŸ”’
1174 Immediate Food Delivery II MySQL O(n) O(m) Medium πŸ”’
1179 Reformat Department Table MySQL O(n) O(n) Easy πŸ”’
1193 Monthly Transactions I MySQL O(n) O(n) Medium πŸ”’
1194 Tournament Winners MySQL O(m + n + nlogn) O(m + n) Hard πŸ”’
1204 Last Person to Fit in the Elevator MySQL O(nlogn) O(n) Medium πŸ”’
1205 Monthly Transactions II MySQL O(n) O(n) Medium πŸ”’
1211 Queries Quality and Percentage MySQL O(n) O(n) Easy
1212 Team Scores in Football Tournament MySQL O(nlogn) O(n) Medium
1225 Report Contiguous Dates MySQL O(nlogn) O(n) Hard πŸ”’
1241 Number of Comments per Post MySQL O(n) O(n) Easy πŸ”’
1251 Average Selling Price MySQL O(n) O(n) Easy πŸ”’
1264 Page Recommendations MySQL O(m + n) O(m) Medium πŸ”’
1270 All People Report to the Given Manager MySQL O(n) O(n) Medium πŸ”’
1280 Students and Examinations MySQL O((m * n) * log(m * n)) O(m * n) Easy πŸ”’
1285 Find the Start and End Number of Continuous Ranges MySQL O(n) O(n) Medium πŸ”’
1294 Weather Type in Each Country MySQL O(m + n) O(n) Easy πŸ”’
1303 Find the Team Size MySQL O(n) O(n) Easy πŸ”’
1308 Running Total for Different Genders MySQL O(nlogn) O(n) Medium πŸ”’
1321 Restaurant Growth MySQL O(nlogn) O(n) Medium πŸ”’
1322 Ads Performance MySQL O(nlogn) O(n) Easy πŸ”’
1327 List the Products Ordered in a Period MySQL O(n) O(n) Easy πŸ”’
1336 Number of Transactions per Visit MySQL O(m + n) O(m + n) Medium πŸ”’
1341 Movie Rating MySQL O(nlogn) O(n) Medium πŸ”’
1350 Students With Invalid Departments MySQL O(n) O(n) Easy πŸ”’
1355 Activity Participants MySQL O(n) O(n) Medium πŸ”’
1364 Number of Trusted Contacts of a Customer MySQL O(n + m + l + nlogn) O(n + m + l) Medium πŸ”’
1369 Get the Second Most Recent Activity MySQL O(nlogn) O(n) Hard πŸ”’
1378 Replace Employee ID With The Unique Identifier MySQL O(n) O(n) Easy πŸ”’
1384 Total Sales Amount by Year MySQL O(nlogn) O(n) Hard πŸ”’
1393 Capital Gain/Loss MySQL O(n) O(n) Medium πŸ”’
1398 Customers Who Bought Products A and B but Not C MySQL O(m + n) O(m + n) Medium πŸ”’
1407 Top Travellers MySQL O(m + nlogn) O(m + n) Easy πŸ”’
1412 Find the Quiet Students in All Exams MySQL O(m + nlogn) O(m + n) Hard πŸ”’
1421 NPV Queries MySQL O(n) O(n) Medium πŸ”’
1435 Create a Session Bar Chart MySQL O(n) O(1) Easy πŸ”’
1440 Evaluate Boolean Expression MySQL O(n) O(n) Medium πŸ”’
1445 Apples & Oranges MySQL O(n) O(n) Medium πŸ”’
1454 Active Users MySQL O(nlogn) O(n) Medium πŸ”’
1459 Rectangles Area MySQL O(n^2) O(n^2) Medium πŸ”’
1468 Calculate Salaries MySQL O(m + n) O(m + n) Easy πŸ”’
1479 Sales by Day of the Week MySQL O(m + n) O(n) Hard πŸ”’
1484 Group Sold Products By The Date MySQL O(nlogn) O(n) Easy πŸ”’
1495 Friendly Movies Streamed Last Month MySQL O(n) O(n) Easy πŸ”’
1501 Countries You Can Safely Invest In MySQL O(n) O(n) Medium πŸ”’
1511 Customer Order Frequency MySQL O(n) O(n) Easy πŸ”’
1517 Find Users With Valid E-Mails MySQL O(n) O(n) Easy πŸ”’ Regex
1527 Patients With a Condition MySQL O(n) O(n) Easy πŸ”’ Regex
1532 The Most Recent Three Orders MySQL O(nlogn) O(n) Medium πŸ”’
1543 Fix Product Name Format MySQL O(nlogn) O(n) Easy πŸ”’
1549 The Most Recent Orders for Each Product MySQL O(nlogn) O(n) Medium πŸ”’
1555 Bank Account Summary MySQL O(m + n) O(m + n) Medium πŸ”’
1565 Unique Orders and Customers Per Month MySQL O(n) O(n) Easy πŸ”’
1571 Warehouse Manager MySQL O(n) O(n) Medium πŸ”’
1581 Customer Who Visited but Did Not Make Any Transactions MySQL O(n) O(n) Easy πŸ”’
1587 Bank Account Summary II MySQL O(m + n) O(m + n) Easy πŸ”’
1596 The Most Frequently Ordered Products for Each Customer MySQL O(n) O(n) Medium πŸ”’
1607 Sellers With No Sales MySQL O(nlogm) O(n + m) Medium πŸ”’
1613 Find the Missing IDs MySQL O(n^2) O(n) Medium πŸ”’
1623 All Valid Triplets That Can Represent a Country MySQL O(n^3) O(n^3) Easy πŸ”’
1633 Percentage of Users Attended a Contest MySQL O(m + nlogn) O(n) Easy πŸ”’
1635 Hopper Company Queries I MySQL O(d + r + tlogt) O(d + r + t) Hard πŸ”’
1645 Hopper Company Queries II MySQL O(d + r + tlogt) O(d + r + t) Hard πŸ”’
1651 Hopper Company Queries III MySQL O(d + r + tlogt) O(d + r + t) Hard πŸ”’
1661 Average Time of Process per Machine MySQL O(n) O(n) Easy πŸ”’
1667 Fix Names in a Table MySQL O(nlogn) O(n) Easy πŸ”’
1677 Product's Worth Over Invoices MySQL O(nlogn) O(n) Easy πŸ”’
1683 Invalid Tweets MySQL O(n) O(n) Easy πŸ”’
1693 Daily Leads and Partners MySQL O(n) O(n) Easy πŸ”’
1699 Number of Calls Between Two Persons MySQL O(n) O(n) Medium πŸ”’
1709 Biggest Window Between Visits MySQL O(nlogn) O(n) Medium πŸ”’
1715 Count Apples and Oranges MySQL O(n) O(n) Medium πŸ”’
1729 Find Followers Count MySQL O(nlogn) O(n) Easy πŸ”’
1731 The Number of Employees Which Report to Each Employee MySQL O(nlogn) O(n) Easy πŸ”’
1741 Find Total Time Spent by Each Employee MySQL O(nlogn) O(n) Easy πŸ”’
1747 Leetflex Banned Accounts MySQL O(n^2) O(n) Medium πŸ”’
1757 Recyclable and Low Fat Products MySQL O(n) O(n) Easy πŸ”’
1767 Find the Subtasks That Did Not Execute MySQL O(n * c) O(n * c) Hard πŸ”’
1777 Product's Price for Each Store MySQL O(n) O(n) Easy πŸ”’
1783 Grand Slam Titles MySQL O(n) O(n) Medium πŸ”’
1789 Primary Department for Each Employee MySQL O(n) O(n) Easy πŸ”’
1795 Rearrange Products Table MySQL O(n) O(n) Easy πŸ”’
1809 Ad-Free Sessions MySQL O(n) O(n) Easy πŸ”’
1811 Find Interview Candidates MySQL O(nlogn) O(n) Medium πŸ”’
1821 Find Customers With Positive Revenue this Year MySQL O(n) O(n) Easy πŸ”’
1831 Maximum Transaction Each Day MySQL O(nlogn) O(n) Medium πŸ”’
1841 League Statistics MySQL O(nlogn) O(n) Medium πŸ”’
1843 Suspicious Bank Accounts MySQL O(nlogn) O(n) Medium πŸ”’
1853 Convert Date Format MySQL O(n) O(n) Easy πŸ”’
1867 Orders With Maximum Quantity Above Average MySQL O(n) O(n) Easy πŸ”’
1873 Calculate Special Bonus MySQL O(n) O(n) Easy πŸ”’
1875 Group Employees of the Same Salary MySQL O(nlogn) O(n) Medium πŸ”’
1890 The Latest Login in 2020 MySQL O(n) O(n) Easy πŸ”’
1892 Page Recommendations II MySQL O(n * m) O(n * m) Hard πŸ”’
1907 Count Salary Categories MySQL O(n) O(n) Medium πŸ”’
1917 Leetcodify Friends Recommendations MySQL O(n^2) O(n^2) Hard πŸ”’
1919 Leetcodify Similar Friends MySQL O(n * l) O(n * l) Hard πŸ”’
1934 Confirmation Rate MySQL O(n + m) O(n + m) Medium πŸ”’
1939 Users That Actively Request Confirmation Messages MySQL O(nlogn) O(n) Easy πŸ”’
1949 Strong Friendship MySQL O(n^3) O(n^2) Medium πŸ”’
1951 All the Pairs With the Maximum Number of Common Followers MySQL O(n^3) O(n^2) Medium πŸ”’
1965 Employees With Missing Information MySQL O(nlogn) O(n) Easy πŸ”’
1972 First and Last Call On the Same Day MySQL O(n) O(n) Hard πŸ”’
1978 Employees Whose Manager Left the Company MySQL O(nlogn) O(n) Easy πŸ”’
1988 Find Cutoff Score for Each School MySQL O(n * m) O(n * m) Medium πŸ”’
1990 Count the Number of Experiments MySQL O(n) O(n) Easy πŸ”’
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 πŸ”’


Shell Script

# Title Solution Time Space Difficulty Tag Note


About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 54.1%
  • Python 45.5%
  • TypeScript 0.2%
  • Java 0.2%
  • Go 0.0%
  • Shell 0.0%