Skip to content

Latest commit

 

History

History
612 lines (603 loc) · 131 KB

two-pointers.md

File metadata and controls

612 lines (603 loc) · 131 KB

Two Pointers LeetCode Problems

A collection of LeetCode problems solved using Two Pointers pattern techniques, explanations, and complexity analysis.

Problems

Easy

# Problem Language Time Space Explanation
9 Palindrome Number Python O(n) O(1) Explanation
21 Merge Two Sorted Lists JavaScript, Python O(n) O(1) Explanation
69 Sqrt(x) Python O(n) O(1) Explanation
83 Remove Duplicates from Sorted List PHP, Python O(n) O(1) Explanation
125 Valid Palindrome PHP O(n) O(1) Explanation
160 Intersection of Two Linked Lists JavaScript, PHP O(n) O(1) Explanation
190 Reverse Bits Python O(n) O(1) Explanation
203 Remove Linked List Elements PHP O(n) O(1) Explanation
206 Reverse Linked List JavaScript, PHP, Python O(n) O(1) Explanation
228 Summary Ranges PHP O(n) O(1) Explanation
278 First Bad Version C++ O(n) O(1) Explanation
303 Range Sum Query - Immutable C++ O(n) O(1) Explanation
344 Reverse String Python O(n) O(1) Explanation
345 Reverse Vowels of a String JavaScript, Python O(n) O(1) Explanation
349 Intersection of Two Arrays Python O(n) O(1) Explanation
350 Intersection of Two Arrays II Python O(n) O(1) Explanation
367 Valid Perfect Square Python O(n) O(1) Explanation
374 Guess Number Higher or Lower JavaScript, Python O(n) O(1) Explanation
409 Longest Palindrome Python O(n) O(1) Explanation
441 Arranging Coins Python O(n) O(1) Explanation
541 Reverse String II Python O(n) O(1) Explanation
605 Can Place Flowers JavaScript, Python O(n) O(1) Explanation
671 Second Minimum Node In a Binary Tree Python O(n) O(1) Explanation
680 Valid Palindrome II Python O(n) O(1) Explanation
693 Binary Number with Alternating Bits Python O(n) O(1) Explanation
724 Find Pivot Index JavaScript, Python O(n) O(1) Explanation
762 Prime Number of Set Bits in Binary Representation Python O(n) O(1) Explanation
830 Positions of Large Groups Python O(n) O(1) Explanation
859 Buddy Strings Python O(n) O(1) Explanation
917 Reverse Only Letters Python O(n) O(1) Explanation
941 Valid Mountain Array Python O(n) O(1) Explanation
1071 Greatest Common Divisor of Strings JavaScript, Python O(n) O(1) Explanation
1252 Cells with Odd Values in a Matrix Python O(n) O(1) Explanation
1299 Replace Elements with Greatest Element on Right Side Python O(n) O(1) Explanation
1309 Decrypt String from Alphabet to Integer Mapping Python O(n) O(1) Explanation
1370 Increasing Decreasing String Python O(n) O(1) Explanation
1380 Lucky Numbers in a Matrix Python O(n) O(1) Explanation
1417 Reformat The String Python O(n) O(1) Explanation
1539 Kth Missing Positive Number JavaScript O(n) O(1) Explanation
1560 Most Visited Sector in a Circular Track Python O(n) O(1) Explanation
1576 Replace All ?'s to Avoid Consecutive Repeating Characters Python O(n) O(1) Explanation
1619 Mean of Array After Removing Some Elements C++ O(n) O(1) Explanation
1629 Slowest Key C++ O(n) O(1) Explanation
1637 Widest Vertical Area Between Two Points Containing No Points C++ O(n) O(1) Explanation
1684 Count the Number of Consistent Strings C++ O(n) O(1) Explanation
1710 Maximum Units on a Truck C++ O(n) O(1) Explanation
1742 Maximum Number of Balls in a Box C++ O(n) O(1) Explanation
1763 Longest Nice Substring C++ O(n) O(1) Explanation
1800 Maximum Ascending Subarray Sum C++ O(n) O(1) Explanation
1848 Minimum Distance to the Target Element C++ O(n) O(1) Explanation
1893 Check if All the Integers in a Range Are Covered C++ O(n) O(1) Explanation
1967 Number of Strings That Appear as Substrings in Word Kotlin O(n) O(1) Explanation
1991 Find the Middle Index in Array JavaScript O(n) O(1) Explanation
2042 Check if Numbers Are Ascending in a Sentence JavaScript O(n) O(1) Explanation
2108 Find First Palindromic String in the Array JavaScript O(n) O(1) Explanation
2119 A Number After a Double Reversal Python O(n) O(1) Explanation
2248 Intersection of Multiple Arrays Python O(n) O(1) Explanation
2413 Smallest Even Multiple Python O(n) O(1) Explanation
2460 Apply Operations to an Array JavaScript O(n) O(1) Explanation
2500 Delete Greatest Value in Each Row JavaScript O(n) O(1) Explanation
2562 Find the Array Concatenation Value JavaScript O(n) O(1) Explanation
2595 Number of Even and Odd Bits Python O(n) O(1) Explanation
2697 Lexicographically Smallest Palindrome Python O(n) O(1) Explanation
2760 Longest Even Odd Subarray With Threshold Python O(n) O(1) Explanation
2848 Points That Intersect With Cars JavaScript O(n) O(1) Explanation
2877 Create a DataFrame from List Python O(n) O(1) Explanation
2878 Get the Size of a DataFrame Python O(n) O(1) Explanation
2881 Create a New Column Python O(n) O(1) Explanation
3090 Maximum Length Substring With Two Occurrences Swift O(n) O(1) Explanation
3264 Final Array State After K Multiplication Operations I JavaScript O(n) O(1) Explanation
3427 Sum of Variable Length Subarrays JavaScript O(n) O(1) Explanation
3438 Find Valid Pair of Adjacent Digits in String JavaScript O(n) O(1) Explanation
3658 GCD of Odd and Even Sums Kotlin O(n) O(1) Explanation
3745 Maximize Expression of Three Elements Python O(n) O(1) Explanation
3754 Concatenate Non-Zero Digits and Multiply by Sum I Kotlin O(n) O(1) Explanation
3925 Concatenate Array With Reverse Python O(n) O(1) Explanation
4010 Maximize Pair Strength Using GCD JavaScript O(n) O(1) Explanation

Medium

# Problem Language Time Space Explanation
2 Add Two Numbers JavaScript, Python O(n) O(1) Explanation
7 Reverse Integer JavaScript O(n) O(1) Explanation
11 Container With Most Water JavaScript, Python O(n) O(1) Explanation
24 Swap Nodes in Pairs JavaScript, Python O(n) O(1) Explanation
29 Divide Two Integers Python O(n) O(1) Explanation
43 Multiply Strings Python O(n) O(1) Explanation
45 Jump Game II JavaScript, Python O(n) O(1) Explanation
53 Maximum Subarray JavaScript, Python O(n) O(1) Explanation
54 Spiral Matrix JavaScript, Python O(n) O(1) Explanation
59 Spiral Matrix II Python O(n) O(1) Explanation
61 Rotate List C++ O(n) O(1) Explanation
64 Minimum Path Sum JavaScript, Python O(n) O(1) Explanation
74 Search a 2D Matrix JavaScript, Python O(n) O(1) Explanation
75 Sort Colors JavaScript, PHP O(n) O(1) Explanation
80 Remove Duplicates from Sorted Array II PHP O(n) O(1) Explanation
82 Remove Duplicates from Sorted List II PHP O(n) O(1) Explanation
86 Partition List JavaScript O(n) O(1) Explanation
92 Reverse Linked List II JavaScript O(n) O(1) Explanation
102 Binary Tree Level Order Traversal JavaScript O(n) O(1) Explanation
103 Binary Tree Zigzag Level Order Traversal JavaScript O(n) O(1) Explanation
130 Surrounded Regions JavaScript O(n) O(1) Explanation
131 Palindrome Partitioning Python O(n) O(1) Explanation
134 Gas Station JavaScript O(n) O(1) Explanation
138 Copy List with Random Pointer JavaScript, Python O(n) O(1) Explanation
147 Insertion Sort List Python O(n) O(1) Explanation
167 Two Sum II - Input Array Is Sorted JavaScript O(n) O(1) Explanation
189 Rotate Array JavaScript O(n) O(1) Explanation
200 Number of Islands JavaScript, Python O(n) O(1) Explanation
201 Bitwise AND of Numbers Range JavaScript O(n) O(1) Explanation
207 Course Schedule JavaScript, Python O(n) O(1) Explanation
215 Kth Largest Element in an Array JavaScript, Python O(n) O(1) Explanation
222 Count Complete Tree Nodes JavaScript O(n) O(1) Explanation
227 Basic Calculator II JavaScript O(n) O(1) Explanation
237 Delete Node in a Linked List JavaScript O(n) O(1) Explanation
240 Search a 2D Matrix II JavaScript, Python O(n) O(1) Explanation
275 H-Index II JavaScript O(n) O(1) Explanation
306 Additive Number Python O(n) O(1) Explanation
307 Range Sum Query - Mutable JavaScript, Python O(n) O(1) Explanation
324 Wiggle Sort II JavaScript O(n) O(1) Explanation
328 Odd Even Linked List JavaScript, Python O(n) O(1) Explanation
341 Flatten Nested List Iterator JavaScript O(n) O(1) Explanation
373 Find K Pairs with Smallest Sums JavaScript O(n) O(1) Explanation
378 Kth Smallest Element in a Sorted Matrix JavaScript O(n) O(1) Explanation
380 Insert Delete GetRandom O(1) JavaScript, Python O(n) O(1) Explanation
382 Linked List Random Node JavaScript O(n) O(1) Explanation
386 Lexicographical Numbers Python O(n) O(1) Explanation
394 Decode String JavaScript, Python O(n) O(1) Explanation
419 Battleships in a Board JavaScript O(n) O(1) Explanation
427 Construct Quad Tree JavaScript O(n) O(1) Explanation
430 Flatten a Multilevel Doubly Linked List Python O(n) O(1) Explanation
442 Find All Duplicates in an Array Python O(n) O(1) Explanation
445 Add Two Numbers II JavaScript O(n) O(1) Explanation
454 4Sum II Python O(n) O(1) Explanation
456 132 Pattern Python O(n) O(1) Explanation
475 Heaters Python O(n) O(1) Explanation
481 Magical String Python O(n) O(1) Explanation
491 Non-decreasing Subsequences Python O(n) O(1) Explanation
498 Diagonal Traverse JavaScript O(n) O(1) Explanation
503 Next Greater Element II Python O(n) O(1) Explanation
519 Random Flip Matrix Python O(n) O(1) Explanation
528 Random Pick with Weight JavaScript O(n) O(1) Explanation
542 01 Matrix Python O(n) O(1) Explanation
556 Next Greater Element III Python O(n) O(1) Explanation
581 Shortest Unsorted Continuous Subarray Python O(n) O(1) Explanation
611 Valid Triangle Number JavaScript O(n) O(1) Explanation
654 Maximum Binary Tree Python O(n) O(1) Explanation
658 Find K Closest Elements JavaScript O(n) O(1) Explanation
662 Maximum Width of Binary Tree Python O(n) O(1) Explanation
678 Valid Parenthesis String Python O(n) O(1) Explanation
707 Design Linked List JavaScript O(n) O(1) Explanation
713 Subarray Product Less Than K Python O(n) O(1) Explanation
722 Remove Comments Python O(n) O(1) Explanation
725 Split Linked List in Parts JavaScript O(n) O(1) Explanation
729 My Calendar I JavaScript O(n) O(1) Explanation
731 My Calendar II Python O(n) O(1) Explanation
777 Swap Adjacent in LR String Python O(n) O(1) Explanation
794 Valid Tic-Tac-Toe State JavaScript O(n) O(1) Explanation
817 Linked List Components JavaScript O(n) O(1) Explanation
842 Split Array into Fibonacci Sequence Python O(n) O(1) Explanation
845 Longest Mountain in Array Python O(n) O(1) Explanation
855 Exam Room JavaScript O(n) O(1) Explanation
865 Smallest Subtree with all the Deepest Nodes JavaScript O(n) O(1) Explanation
866 Prime Palindrome Python O(n) O(1) Explanation
873 Length of Longest Fibonacci Subsequence Python O(n) O(1) Explanation
875 Koko Eating Bananas JavaScript O(n) O(1) Explanation
885 Spiral Matrix III JavaScript O(n) O(1) Explanation
907 Sum of Subarray Minimums Python O(n) O(1) Explanation
923 3Sum With Multiplicity Python O(n) O(1) Explanation
934 Shortest Bridge Python O(n) O(1) Explanation
962 Maximum Width Ramp Python O(n) O(1) Explanation
967 Numbers With Same Consecutive Differences Python O(n) O(1) Explanation
971 Flip Binary Tree To Match Preorder Traversal Python O(n) O(1) Explanation
988 Smallest String Starting From Leaf Python O(n) O(1) Explanation
1004 Max Consecutive Ones III JavaScript, Python O(n) O(1) Explanation
1019 Next Greater Node In Linked List Python O(n) O(1) Explanation
1020 Number of Enclaves Python O(n) O(1) Explanation
1026 Maximum Difference Between Node and Ancestor Python O(n) O(1) Explanation
1034 Coloring A Border Python O(n) O(1) Explanation
1042 Flower Planting With No Adjacent JavaScript O(n) O(1) Explanation
1061 Lexicographically Smallest Equivalent String Python O(n) O(1) Explanation
1080 Insufficient Nodes in Root to Leaf Paths JavaScript O(n) O(1) Explanation
1091 Shortest Path in Binary Matrix Python O(n) O(1) Explanation
1110 Delete Nodes And Return Forest JavaScript O(n) O(1) Explanation
1116 Print Zero Even Odd Java O(n) O(1) Explanation
1130 Minimum Cost Tree From Leaf Values Python O(n) O(1) Explanation
1138 Alphabet Board Path Python O(n) O(1) Explanation
1139 Largest 1-Bordered Square JavaScript O(n) O(1) Explanation
1146 Snapshot Array JavaScript O(n) O(1) Explanation
1162 As Far from Land as Possible Python O(n) O(1) Explanation
1169 Invalid Transactions Python O(n) O(1) Explanation
1177 Can Make Palindrome from Substring Python O(n) O(1) Explanation
1222 Queens That Can Attack the King JavaScript O(n) O(1) Explanation
1237 Find Positive Integer Solution for a Given Equation Python O(n) O(1) Explanation
1239 Maximum Length of a Concatenated String with Unique Characters Python O(n) O(1) Explanation
1253 Reconstruct a 2-Row Binary Matrix JavaScript O(n) O(1) Explanation
1254 Number of Closed Islands Python O(n) O(1) Explanation
1324 Print Words Vertically Python O(n) O(1) Explanation
1328 Break a Palindrome Python O(n) O(1) Explanation
1329 Sort the Matrix Diagonally JavaScript O(n) O(1) Explanation
1381 Design a Stack With Increment Operation Python O(n) O(1) Explanation
1391 Check if There is a Valid Path in a Grid Python O(n) O(1) Explanation
1395 Count Number of Teams JavaScript O(n) O(1) Explanation
1400 Construct K Palindrome Strings Python O(n) O(1) Explanation
1405 Longest Happy String Python O(n) O(1) Explanation
1452 People Whose List of Favorite Companies Is Not a Subset of Another List Python O(n) O(1) Explanation
1457 Pseudo-Palindromic Paths in a Binary Tree Python O(n) O(1) Explanation
1472 Design Browser History Python O(n) O(1) Explanation
1493 Longest Subarray of 1's After Deleting One Element JavaScript O(n) O(1) Explanation
1498 Number of Subsequences That Satisfy the Given Sum Condition JavaScript O(n) O(1) Explanation
1519 Number of Nodes in the Sub-Tree With the Same Label Python O(n) O(1) Explanation
1530 Number of Good Leaf Nodes Pairs JavaScript O(n) O(1) Explanation
1536 Minimum Swaps to Arrange a Binary Grid JavaScript O(n) O(1) Explanation
1557 Minimum Number of Vertices to Reach All Nodes Python O(n) O(1) Explanation
1574 Shortest Subarray to be Removed to Make Array Sorted Python O(n) O(1) Explanation
1583 Count Unhappy Friends Python O(n) O(1) Explanation
1593 Split a String Into the Max Number of Unique Substrings Python O(n) O(1) Explanation
1609 Even Odd Tree Python O(n) O(1) Explanation
1616 Split Two Strings to Make Palindrome Python O(n) O(1) Explanation
1625 Lexicographically Smallest String After Applying Operations Python O(n) O(1) Explanation
1638 Count Substrings That Differ by One Character Python O(n) O(1) Explanation
1654 Minimum Jumps to Reach Home Python O(n) O(1) Explanation
1670 Design Front Middle Back Queue Python O(n) O(1) Explanation
1673 Find the Most Competitive Subsequence Python O(n) O(1) Explanation
1679 Max Number of K-Sum Pairs JavaScript O(n) O(1) Explanation
1685 Sum of Absolute Differences in a Sorted Array JavaScript O(n) O(1) Explanation
1706 Where Will the Ball Fall Python O(n) O(1) Explanation
1712 Ways to Split Array Into Three Subarrays Python O(n) O(1) Explanation
1717 Maximum Score From Removing Substrings C++ O(n) O(1) Explanation
1721 Swapping Nodes in a Linked List JavaScript O(n) O(1) Explanation
1754 Largest Merge Of Two Strings Python O(n) O(1) Explanation
1765 Map of Highest Peak Python O(n) O(1) Explanation
1775 Equal Sum Arrays With Minimum Number of Operations Python O(n) O(1) Explanation
1786 Number of Restricted Paths From First to Last Node Python O(n) O(1) Explanation
1802 Maximum Value at a Given Index in a Bounded Array Python O(n) O(1) Explanation
1818 Minimum Absolute Sum Difference Python O(n) O(1) Explanation
1828 Queries on Number of Points Inside a Circle Python O(n) O(1) Explanation
1845 Seat Reservation Manager JavaScript O(n) O(1) Explanation
1850 Minimum Adjacent Swaps to Reach the Kth Smallest Number Python O(n) O(1) Explanation
1855 Maximum Distance Between a Pair of Values Python O(n) O(1) Explanation
1856 Maximum Subarray Min-Product Python O(n) O(1) Explanation
1881 Maximum Value after Insertion Python O(n) O(1) Explanation
1882 Process Tasks Using Servers Python O(n) O(1) Explanation
1888 Minimum Number of Flips to Make the Binary String Alternating Python O(n) O(1) Explanation
1904 The Number of Full Rounds You Have Played Python O(n) O(1) Explanation
1905 Count Sub Islands Python O(n) O(1) Explanation
1906 Minimum Absolute Difference Queries JavaScript O(n) O(1) Explanation
1926 Nearest Exit from Entrance in Maze JavaScript O(n) O(1) Explanation
1942 The Number of the Smallest Unoccupied Chair Python O(n) O(1) Explanation
1946 Largest Number After Mutating Substring Python O(n) O(1) Explanation
1976 Number of Ways to Arrive at Destination Python O(n) O(1) Explanation
1992 Find All Groups of Farmland Python O(n) O(1) Explanation
2002 Maximum Product of the Length of Two Palindromic Subsequences JavaScript O(n) O(1) Explanation
2039 The Time When the Network Becomes Idle JavaScript O(n) O(1) Explanation
2049 Count Nodes With the Highest Score JavaScript O(n) O(1) Explanation
2055 Plates Between Candles Python O(n) O(1) Explanation
2058 Find the Minimum and Maximum Number of Nodes Between Critical Points C++ O(n) O(1) Explanation
2059 Minimum Operations to Convert Number Python O(n) O(1) Explanation
2074 Reverse Nodes in Even Length Groups JavaScript O(n) O(1) Explanation
2075 Decode the Slanted Ciphertext Python O(n) O(1) Explanation
2096 Step-By-Step Directions From a Binary Tree Node to Another JavaScript O(n) O(1) Explanation
2100 Find Good Days to Rob the Bank JavaScript O(n) O(1) Explanation
2101 Detonate the Maximum Bombs Python O(n) O(1) Explanation
2116 Check if a Parentheses String Can Be Valid Python O(n) O(1) Explanation
2120 Execution of All Suffix Instructions Staying in a Grid Python O(n) O(1) Explanation
2131 Longest Palindrome by Concatenating Two Letter Words Python O(n) O(1) Explanation
2134 Minimum Swaps to Group All 1's Together II Python O(n) O(1) Explanation
2135 Count Words Obtained After Adding a Letter Python O(n) O(1) Explanation
2146 K Highest Ranked Items Within a Price Range Python O(n) O(1) Explanation
2162 Minimum Cost to Set Cooking Time Python O(n) O(1) Explanation
2181 Merge Nodes in Between Zeros JavaScript O(n) O(1) Explanation
2182 Construct String With Repeat Limit Python O(n) O(1) Explanation
2192 All Ancestors of a Node in a Directed Acyclic Graph JavaScript O(n) O(1) Explanation
2212 Maximum Points in an Archery Competition Python O(n) O(1) Explanation
2232 Minimize Result by Adding Parentheses to Expression Python O(n) O(1) Explanation
2256 Minimum Average Difference JavaScript O(n) O(1) Explanation
2265 Count Nodes Equal to Average of Subtree JavaScript O(n) O(1) Explanation
2270 Number of Ways to Split Array JavaScript O(n) O(1) Explanation
2271 Maximum White Tiles Covered by a Carpet Python O(n) O(1) Explanation
2285 Maximum Total Importance of Roads JavaScript O(n) O(1) Explanation
2289 Steps to Make Array Non-decreasing Python O(n) O(1) Explanation
2300 Successful Pairs of Spells and Potions JavaScript O(n) O(1) Explanation
2316 Count Unreachable Pairs of Nodes in an Undirected Graph Python O(n) O(1) Explanation
2326 Spiral Matrix IV JavaScript O(n) O(1) Explanation
2333 Minimum Sum of Squared Difference JavaScript O(n) O(1) Explanation
2368 Reachable Nodes With Restrictions Python O(n) O(1) Explanation
2374 Node With Highest Edge Score JavaScript O(n) O(1) Explanation
2381 Shifting Letters II JavaScript O(n) O(1) Explanation
2397 Maximum Rows Covered by Columns Python O(n) O(1) Explanation
2400 Number of Ways to Reach a Position After Exactly k Steps JavaScript O(n) O(1) Explanation
2420 Find All Good Indices JavaScript O(n) O(1) Explanation
2429 Minimize XOR Python O(n) O(1) Explanation
2462 Total Cost to Hire K Workers JavaScript O(n) O(1) Explanation
2487 Remove Nodes From Linked List Python O(n) O(1) Explanation
2497 Maximum Star Sum of a Graph JavaScript O(n) O(1) Explanation
2516 Take K of Each Character From Left and Right Python O(n) O(1) Explanation
2523 Closest Prime Numbers in Range JavaScript, Python O(n) O(1) Explanation
2526 Find Consecutive Integers from a Data Stream Python O(n) O(1) Explanation
2542 Maximum Subsequence Score JavaScript O(n) O(1) Explanation
2593 Find Score of an Array After Marking All Elements JavaScript O(n) O(1) Explanation
2601 Prime Subtraction Operation Python O(n) O(1) Explanation
2625 Flatten Deeply Nested Array TypeScript O(n) O(1) Explanation
2679 Sum in a Matrix JavaScript O(n) O(1) Explanation
2698 Find the Punishment Number of an Integer Python O(n) O(1) Explanation
2711 Difference of Number of Distinct Values on Diagonals Python O(n) O(1) Explanation
2721 Execute Asynchronous Functions in Parallel TypeScript O(n) O(1) Explanation
2747 Count Zero Request Servers Python O(n) O(1) Explanation
2807 Insert Greatest Common Divisors in Linked List JavaScript O(n) O(1) Explanation
2812 Find the Safest Path in a Grid Java O(n) O(1) Explanation
2816 Double a Number Represented as a Linked List JavaScript O(n) O(1) Explanation
2817 Minimum Absolute Difference Between Elements With Constraint Python O(n) O(1) Explanation
2830 Maximize the Profit as the Salesman Python O(n) O(1) Explanation
2874 Maximum Value of an Ordered Triplet II JavaScript O(n) O(1) Explanation
2904 Shortest and Lexicographically Smallest Beautiful String C++ O(n) O(1) Explanation
2909 Minimum Sum of Mountain Triplets II JavaScript O(n) O(1) Explanation
2961 Double Modular Exponentiation JavaScript O(n) O(1) Explanation
3006 Find Beautiful Indices in the Given Array I Python O(n) O(1) Explanation
3016 Minimum Number of Pushes to Type Word II C++ O(n) O(1) Explanation
3035 Maximum Palindromes After Operations Python O(n) O(1) Explanation
3066 Minimum Operations to Exceed Threshold Value II JavaScript O(n) O(1) Explanation
3112 Minimum Time to Visit Disappearing Nodes JavaScript O(n) O(1) Explanation
3128 Right Triangles JavaScript O(n) O(1) Explanation
3133 Minimum Array End Python O(n) O(1) Explanation
3143 Maximum Points Inside the Square Python O(n) O(1) Explanation
3217 Delete Nodes From Linked List Present in Array JavaScript O(n) O(1) Explanation
3233 Find the Count of Numbers Which Are Not Special JavaScript O(n) O(1) Explanation
3281 Maximize Score of Numbers in Ranges Python O(n) O(1) Explanation
3319 K-th Largest Perfect Subtree Size in Binary Tree JavaScript O(n) O(1) Explanation
3326 Minimum Division Operations to Make Array Non Decreasing JavaScript O(n) O(1) Explanation
3361 Shift Distance Between Two Strings JavaScript O(n) O(1) Explanation
3362 Zero Array Transformation III JavaScript O(n) O(1) Explanation
3372 Maximize the Number of Target Nodes After Connecting Trees I Python O(n) O(1) Explanation
3380 Maximum Area Rectangle With Point Constraints I JavaScript O(n) O(1) Explanation
3413 Maximum Coins From K Consecutive Bags Python O(n) O(1) Explanation
3453 Separate Squares I Python O(n) O(1) Explanation
3494 Find the Minimum Amount of Time to Brew Potions JavaScript O(n) O(1) Explanation
3499 Maximize Active Section with Trade I C++ O(n) O(1) Explanation
3503 Longest Palindrome After Substring Concatenation I Python O(n) O(1) Explanation
3517 Smallest Palindromic Rearrangement I C++ O(n) O(1) Explanation
3521 Find Product Recommendation Pairs Python O(n) O(1) Explanation
3529 Count Cells in Overlapping Horizontal and Vertical Substrings Python O(n) O(1) Explanation
3542 Minimum Operations to Convert All Elements to Zero Python O(n) O(1) Explanation
3543 Maximum Weighted K-Edge Path JavaScript O(n) O(1) Explanation
3556 Sum of Largest Prime Substrings JavaScript O(n) O(1) Explanation
3578 Count Partitions With Max-Min Difference at Most K JavaScript O(n) O(1) Explanation
3580 Find Consistently Improving Employees Python O(n) O(1) Explanation
3583 Count Special Triplets JavaScript O(n) O(1) Explanation
3601 Find Drivers with Improved Fuel Efficiency Python O(n) O(1) Explanation
3612 Process String with Special Operations I Java O(n) O(1) Explanation
3613 Minimize Maximum Component Cost Python O(n) O(1) Explanation
3619 Count Islands With Total Value Divisible by K Python O(n) O(1) Explanation
3629 Minimum Jumps to Reach End via Prime Teleportation C++ O(n) O(1) Explanation
3635 Earliest Finish Time for Land and Water Rides II Java O(n) O(1) Explanation
3660 Jump Game IX C++ O(n) O(1) Explanation
3669 Balanced K-Factor Decomposition Python O(n) O(1) Explanation
3676 Count Bowl Subarrays Python O(n) O(1) Explanation
3705 Find Golden Hour Customers Python O(n) O(1) Explanation
3716 Find Churn Risk Customers Python O(n) O(1) Explanation
3742 Maximum Path Score in a Grid C++ O(n) O(1) Explanation
3756 Concatenate Non-Zero Digits and Multiply by Sum II Java O(n) O(1) Explanation
3766 Minimum Operations to Make Binary Palindrome Python O(n) O(1) Explanation
3770 Largest Prime from Consecutive Prime Sum JavaScript O(n) O(1) Explanation
3820 Pythagorean Distance Nodes in a Tree Python O(n) O(1) Explanation
3867 Sum of GCD of Formed Pairs C++ O(n) O(1) Explanation
3872 Longest Arithmetic Sequence After Changing At Most One Element Python O(n) O(1) Explanation
3904 Smallest Stable Index II JavaScript O(n) O(1) Explanation
3918 Sum of Primes Between Number and Its Reverse JavaScript O(n) O(1) Explanation
3919 Minimum Cost to Move Between Indices Python O(n) O(1) Explanation
3955 Valid Binary Strings With Cost Limit Python O(n) O(1) Explanation
3970 Shortest Path With At Most K Consecutive Identical Characters Python O(n) O(1) Explanation
3997 Count Dominant Nodes in a Binary Tree JavaScript O(n) O(1) Explanation
4011 Count Subarrays With Even Odd Ratio I Python O(n) O(1) Explanation
4031 Find All Numbers Disappeared in an Array II Python O(n) O(1) Explanation
4036 Lexicographically Largest String After Pair Transformations Python O(n) O(1) Explanation
4045 Count Robot Groups Python O(n) O(1) Explanation
4053 Minimum Operations to Make Every Element Palindromic Python O(n) O(1) Explanation
4098 Minimize the Maximum Value of GCD-Connected Array JavaScript O(n) O(1) Explanation
4103 Remove Elements by Type and Color Python O(n) O(1) Explanation
4104 Count Valid Substrings II C++ O(n) O(1) Explanation

Hard

# Problem Language Time Space Explanation
23 Merge k Sorted Lists JavaScript, Python O(n) O(1) Explanation
25 Reverse Nodes in k-Group JavaScript, Python O(n) O(1) Explanation
42 Trapping Rain Water JavaScript, Python O(n) O(1) Explanation
85 Maximal Rectangle Python O(n) O(1) Explanation
132 Palindrome Partitioning II Python O(n) O(1) Explanation
135 Candy JavaScript, Python O(n) O(1) Explanation
188 Best Time to Buy and Sell Stock IV JavaScript O(n) O(1) Explanation
214 Shortest Palindrome Python O(n) O(1) Explanation
233 Number of Digit One Python O(n) O(1) Explanation
295 Find Median from Data Stream JavaScript O(n) O(1) Explanation
315 Count of Smaller Numbers After Self JavaScript O(n) O(1) Explanation
321 Create Maximum Number Python O(n) O(1) Explanation
327 Count of Range Sum JavaScript O(n) O(1) Explanation
336 Palindrome Pairs Python O(n) O(1) Explanation
354 Russian Doll Envelopes JavaScript O(n) O(1) Explanation
363 Max Sum of Rectangle No Larger Than K Python O(n) O(1) Explanation
381 Insert Delete GetRandom O(1) - Duplicates allowed Python O(n) O(1) Explanation
420 Strong Password Checker Python O(n) O(1) Explanation
479 Largest Palindrome Product Python O(n) O(1) Explanation
488 Zuma Game Python O(n) O(1) Explanation
493 Reverse Pairs JavaScript, Python O(n) O(1) Explanation
502 IPO JavaScript O(n) O(1) Explanation
517 Super Washing Machines Python O(n) O(1) Explanation
564 Find the Closest Palindrome Python O(n) O(1) Explanation
587 Erect the Fence Python O(n) O(1) Explanation
591 Tag Validator Python O(n) O(1) Explanation
632 Smallest Range Covering Elements from K Lists Python O(n) O(1) Explanation
679 24 Game Python O(n) O(1) Explanation
691 Stickers to Spell Word JavaScript O(n) O(1) Explanation
715 Range Module Python O(n) O(1) Explanation
749 Contain Virus Python O(n) O(1) Explanation
753 Cracking the Safe JavaScript O(n) O(1) Explanation
829 Consecutive Numbers Sum Python O(n) O(1) Explanation
847 Shortest Path Visiting All Nodes JavaScript O(n) O(1) Explanation
864 Shortest Path to Get All Keys Python O(n) O(1) Explanation
882 Reachable Nodes In Subdivided Graph Python O(n) O(1) Explanation
887 Super Egg Drop Python O(n) O(1) Explanation
902 Numbers At Most N Given Digit Set Python O(n) O(1) Explanation
906 Super Palindromes Python O(n) O(1) Explanation
943 Find the Shortest Superstring JavaScript O(n) O(1) Explanation
975 Odd Even Jump Python O(n) O(1) Explanation
992 Subarrays with K Different Integers Python O(n) O(1) Explanation
995 Minimum Number of K Consecutive Bit Flips JavaScript O(n) O(1) Explanation
1036 Escape a Large Maze Python O(n) O(1) Explanation
1044 Longest Duplicate Substring Python O(n) O(1) Explanation
1147 Longest Chunked Palindrome Decomposition Python O(n) O(1) Explanation
1172 Dinner Plate Stacks JavaScript O(n) O(1) Explanation
1210 Minimum Moves to Reach Target with Rotations Python O(n) O(1) Explanation
1235 Maximum Profit in Job Scheduling Python O(n) O(1) Explanation
1240 Tiling a Rectangle with the Fewest Squares Python O(n) O(1) Explanation
1255 Maximum Score Words Formed by Letters JavaScript O(n) O(1) Explanation
1263 Minimum Moves to Move a Box to Their Target Location Python O(n) O(1) Explanation
1278 Palindrome Partitioning III Python O(n) O(1) Explanation
1284 Minimum Number of Flips to Convert Binary Matrix to Zero Matrix Python O(n) O(1) Explanation
1293 Shortest Path in a Grid with Obstacles Elimination Python O(n) O(1) Explanation
1312 Minimum Insertion Steps to Make a String Palindrome Python O(n) O(1) Explanation
1354 Construct Target Array With Multiple Sums JavaScript O(n) O(1) Explanation
1368 Minimum Cost to Make at Least One Valid Path in a Grid Python O(n) O(1) Explanation
1397 Find All Good Strings Python O(n) O(1) Explanation
1531 String Compression II Python O(n) O(1) Explanation
1568 Minimum Number of Days to Disconnect Island Python O(n) O(1) Explanation
1575 Count All Possible Routes Python O(n) O(1) Explanation
1585 Check If String Is Transformable With Substring Sort Operations Python O(n) O(1) Explanation
1591 Strange Printer II JavaScript O(n) O(1) Explanation
1606 Find Servers That Handled Most Number of Requests Python O(n) O(1) Explanation
1643 Kth Smallest Instructions JavaScript O(n) O(1) Explanation
1703 Minimum Adjacent Swaps for K Consecutive Ones Python O(n) O(1) Explanation
1707 Maximum XOR With an Element From Array Python O(n) O(1) Explanation
1728 Cat and Mouse II Python O(n) O(1) Explanation
1735 Count Ways to Make Array With Product Python O(n) O(1) Explanation
1745 Palindrome Partitioning IV Python O(n) O(1) Explanation
1771 Maximize Palindrome Length From Subsequences Python O(n) O(1) Explanation
1776 Car Fleet II Python O(n) O(1) Explanation
1782 Count Pairs Of Nodes JavaScript O(n) O(1) Explanation
1793 Maximum Score of a Good Subarray Python O(n) O(1) Explanation
1803 Count Pairs With XOR in a Range Python O(n) O(1) Explanation
1847 Closest Room Python O(n) O(1) Explanation
1862 Sum of Floored Pairs Python O(n) O(1) Explanation
1889 Minimum Space Wasted From Packaging Python O(n) O(1) Explanation
1896 Minimum Cost to Change the Final Value of Expression C++ O(n) O(1) Explanation
1938 Maximum Genetic Difference Query Python O(n) O(1) Explanation
1944 Number of Visible People in a Queue Python O(n) O(1) Explanation
1948 Delete Duplicate Folders in System Python O(n) O(1) Explanation
1960 Maximum Product of the Length of Two Palindromic Substrings Python O(n) O(1) Explanation
1964 Find the Longest Valid Obstacle Course at Each Position JavaScript O(n) O(1) Explanation
1977 Number of Ways to Separate Numbers Python O(n) O(1) Explanation
1994 The Number of Good Subsets Python O(n) O(1) Explanation
2030 Smallest K-Length Subsequence With Occurrences of a Letter Python O(n) O(1) Explanation
2035 Partition Array Into Two Arrays to Minimize Sum Difference Python O(n) O(1) Explanation
2040 Kth Smallest Product of Two Sorted Arrays Python O(n) O(1) Explanation
2045 Second Minimum Time to Reach Destination Python O(n) O(1) Explanation
2050 Parallel Courses III JavaScript O(n) O(1) Explanation
2081 Sum of k-Mirror Numbers C++ O(n) O(1) Explanation
2106 Maximum Fruits Harvested After at Most K Steps Python O(n) O(1) Explanation
2127 Maximum Employees to Be Invited to a Meeting JavaScript O(n) O(1) Explanation
2193 Minimum Number of Moves to Make Palindrome JavaScript O(n) O(1) Explanation
2234 Maximum Total Beauty of the Gardens Python O(n) O(1) Explanation
2242 Maximum Score of a Node Sequence JavaScript O(n) O(1) Explanation
2251 Number of Flowers in Full Bloom Python O(n) O(1) Explanation
2258 Escape the Spreading Fire Python O(n) O(1) Explanation
2267 Check if There Is a Valid Parentheses String Path C++ O(n) O(1) Explanation
2281 Sum of Total Strength of Wizards Python O(n) O(1) Explanation
2286 Booking Concert Tickets in Groups JavaScript O(n) O(1) Explanation
2290 Minimum Obstacle Removal to Reach Corner Python O(n) O(1) Explanation
2328 Number of Increasing Paths in a Grid JavaScript O(n) O(1) Explanation
2334 Subarray With Elements Greater Than Varying Threshold Python O(n) O(1) Explanation
2354 Number of Excellent Pairs C++ O(n) O(1) Explanation
2382 Maximum Segment Sum After Removals Python O(n) O(1) Explanation
2402 Meeting Rooms III Python O(n) O(1) Explanation
2407 Longest Increasing Subsequence II JavaScript O(n) O(1) Explanation
2426 Number of Pairs Satisfying Inequality JavaScript O(n) O(1) Explanation
2440 Create Components With Same Value Python O(n) O(1) Explanation
2454 Next Greater Element IV Python O(n) O(1) Explanation
2468 Split Message Based on Limit Python O(n) O(1) Explanation
2472 Maximum Number of Non-overlapping Palindrome Substrings JavaScript O(n) O(1) Explanation
2493 Divide Nodes Into the Maximum Number of Groups Python O(n) O(1) Explanation
2508 Add Edges to Make Degrees of All Nodes Even Python O(n) O(1) Explanation
2532 Time to Cross a Bridge Python O(n) O(1) Explanation
2552 Count Increasing Quadruplets Python O(n) O(1) Explanation
2565 Subsequence With the Minimum Score Python O(n) O(1) Explanation
2573 Find the String with LCP Python O(n) O(1) Explanation
2589 Minimum Time to Complete All Tasks C++ O(n) O(1) Explanation
2612 Minimum Reverse Operations Python O(n) O(1) Explanation
2617 Minimum Number of Visited Cells in a Grid Python O(n) O(1) Explanation
2709 Greatest Common Divisor Traversal Python O(n) O(1) Explanation
2736 Maximum Sum Queries JavaScript O(n) O(1) Explanation
2751 Robot Collisions Python O(n) O(1) Explanation
2791 Count Paths That Can Form a Palindrome in a Tree Python O(n) O(1) Explanation
2835 Minimum Operations to Form Subsequence With Target Sum Python O(n) O(1) Explanation
2858 Minimum Edge Reversals So Every Node Is Reachable Python O(n) O(1) Explanation
2876 Count Visited Nodes in a Directed Graph JavaScript O(n) O(1) Explanation
2911 Minimum Changes to Make K Semi-palindromes Python O(n) O(1) Explanation
2920 Maximum Points After Collecting Coins From All Nodes Python O(n) O(1) Explanation
2926 Maximum Balanced Subsequence Sum JavaScript O(n) O(1) Explanation
2940 Find Building Where Alice and Bob Can Meet JavaScript, Python O(n) O(1) Explanation
2983 Palindrome Rearrangement Queries JavaScript O(n) O(1) Explanation
3008 Find Beautiful Indices in the Given Array II Python O(n) O(1) Explanation
3017 Count the Number of Houses at a Certain Distance II JavaScript O(n) O(1) Explanation
3068 Find the Maximum Sum of Node Values Python O(n) O(1) Explanation
3086 Minimum Moves to Pick K Ones Python O(n) O(1) Explanation
3108 Minimum Cost Walk in Weighted Graph Python O(n) O(1) Explanation
3113 Find the Number of Subarrays Where Boundary Elements Are Maximum Python O(n) O(1) Explanation
3117 Minimum Sum of Values by Dividing Array JavaScript O(n) O(1) Explanation
3145 Find Products of Elements of Big Array Python O(n) O(1) Explanation
3161 Block Placement Queries Python O(n) O(1) Explanation
3187 Peaks in Array JavaScript O(n) O(1) Explanation
3197 Find the Minimum Area to Cover All Ones II Python O(n) O(1) Explanation
3203 Find Minimum Diameter After Merging Two Trees JavaScript O(n) O(1) Explanation
3235 Check if the Rectangle Corner Is Reachable Python O(n) O(1) Explanation
3241 Time Taken to Mark All Nodes JavaScript O(n) O(1) Explanation
3244 Shortest Distance After Road Addition Queries II JavaScript O(n) O(1) Explanation
3245 Alternating Groups III JavaScript O(n) O(1) Explanation
3257 Maximum Value Sum by Placing Three Rooks II Python O(n) O(1) Explanation
3260 Find the Largest Palindrome Divisible by K JavaScript O(n) O(1) Explanation
3266 Final Array State After K Multiplication Operations II JavaScript O(n) O(1) Explanation
3272 Find the Count of Good Integers JavaScript O(n) O(1) Explanation
3283 Maximum Number of Moves to Kill All Pawns Python O(n) O(1) Explanation
3288 Length of the Longest Increasing Path Python O(n) O(1) Explanation
3303 Find the Occurrence of First Almost Equal Substring Python O(n) O(1) Explanation
3311 Construct 2D Grid Matching Graph Layout JavaScript O(n) O(1) Explanation
3327 Check if DFS Strings Are Palindromes Python O(n) O(1) Explanation
3348 Smallest Divisible Digit Product II Python, TypeScript O(n) O(1) Explanation
3352 Count K-Reducible Numbers Less Than N JavaScript O(n) O(1) Explanation
3357 Minimize the Maximum Adjacent Element Difference Python O(n) O(1) Explanation
3363 Find the Maximum Number of Fruits Collected Python O(n) O(1) Explanation
3373 Maximize the Number of Target Nodes After Connecting Trees II Python O(n) O(1) Explanation
3398 Smallest Substring With Identical Characters I Python O(n) O(1) Explanation
3399 Smallest Substring With Identical Characters II Python O(n) O(1) Explanation
3420 Count Non-Decreasing Subarrays After K Operations JavaScript O(n) O(1) Explanation
3430 Maximum and Minimum Sums of at Most Size K Subarrays Python O(n) O(1) Explanation
3444 Minimum Increments for Target Multiples in an Array Python O(n) O(1) Explanation
3454 Separate Squares II Python O(n) O(1) Explanation
3455 Shortest Matching Substring Python O(n) O(1) Explanation
3464 Maximize the Distance Between Points on a Square Python O(n) O(1) Explanation
3501 Maximize Active Section with Trade II PHP O(n) O(1) Explanation
3518 Smallest Palindromic Rearrangement II PHP O(n) O(1) Explanation
3533 Concatenated Divisibility Python O(n) O(1) Explanation
3534 Path Existence Queries in a Graph II PHP O(n) O(1) Explanation
3553 Minimum Weighted Subgraph With the Required Paths II Python O(n) O(1) Explanation
3554 Find Category Recommendation Pairs Python O(n) O(1) Explanation
3559 Number of Ways to Assign Edge Weights II Python O(n) O(1) Explanation
3575 Maximum Good Subtree Score Python O(n) O(1) Explanation
3594 Minimum Time to Transport All Individuals JavaScript O(n) O(1) Explanation
3614 Process String with Special Operations II Python O(n) O(1) Explanation
3615 Longest Palindromic Path in Graph JavaScript O(n) O(1) Explanation
3621 Number of Integers With Popcount-Depth Equal to K I JavaScript O(n) O(1) Explanation
3624 Number of Integers With Popcount-Depth Equal to K II Python O(n) O(1) Explanation
3646 Next Special Palindrome Number Python O(n) O(1) Explanation
3661 Maximum Walls Destroyed by Robots Python O(n) O(1) Explanation
3666 Minimum Operations to Equalize Binary String Python O(n) O(1) Explanation
3671 Sum of Beautiful Subsequences Python O(n) O(1) Explanation
3691 Maximum Total Subarray Value II Python O(n) O(1) Explanation
3710 Maximum Partition Factor Python O(n) O(1) Explanation
3748 Count Stable Subarrays Python O(n) O(1) Explanation
3768 Minimum Inversion Count in Subarrays of Fixed Length Python O(n) O(1) Explanation
3801 Minimum Cost to Merge Sorted Lists Python O(n) O(1) Explanation
3812 Minimum Edge Toggles on a Tree JavaScript O(n) O(1) Explanation
3830 Longest Alternating Subarray After Removing At Most One Element Python O(n) O(1) Explanation
3845 Maximum Subarray XOR with Bounded Range Python O(n) O(1) Explanation
3878 Count Good Subarrays Python O(n) O(1) Explanation
3910 Count Connected Subgraphs with Even Node Sum Python O(n) O(1) Explanation
3911 K-th Smallest Remaining Even Integer in Subarray Queries Python O(n) O(1) Explanation
3920 Maximize Fixed Points After Deletions Python O(n) O(1) Explanation
3928 Minimum Cost to Buy Apples II Python O(n) O(1) Explanation
3956 Maximum Sum of M Non-Overlapping Subarrays I JavaScript O(n) O(1) Explanation
3977 Minimum Time to Reach Target With Limited Power Python O(n) O(1) Explanation
4013 Count Subarrays With Even Odd Ratio II Python O(n) O(1) Explanation
4017 Peaks in Array II Python O(n) O(1) Explanation
4027 Elevator Requests III Python O(n) O(1) Explanation
4037 Maximum Valid Split Positions II JavaScript O(n) O(1) Explanation
4046 Minimum Cost Path With At Most K Turns Python O(n) O(1) Explanation
4051 Count Subarrays with Distant Sums Python O(n) O(1) Explanation
4055 Count Shadow Pairs II Python O(n) O(1) Explanation
4059 Lexicographically Largest Power Array Python O(n) O(1) Explanation
4064 Longest Subarray Divisible by K with At Most One Negation II Python O(n) O(1) Explanation
4100 Minimum Cost Path With Even XOR Parity Python O(n) O(1) Explanation