Skip to content

Latest commit

Β 

History

History
1314 lines (1253 loc) Β· 275 KB

1001-2000.md

File metadata and controls

1314 lines (1253 loc) Β· 275 KB

LanguageΒ  LicenseΒ  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

Database

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


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


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


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 πŸ”’


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


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


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


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


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


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


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


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


Recursion

# Title Solution Time Space Difficulty Tag Note
1106 Parsing A Boolean Expression C++ Python O(n) O(n) Hard


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


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


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


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 πŸ”’


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


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


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


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
1568 Minimum Number of Days to Disconnect Island C++ Python O(m * n) O(m * n) Medium DFS, Persistent Union Find, Tarjan's Algorithm, Articulation Points
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


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


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


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


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 πŸ”’


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 πŸ”’