-
lower_bound():
next smallest element >= target
-
upper_bound():
next smallest element > target
35. Search Insert Position (E-)
34. Find First and Last Position of Element in Sorted Array (M+)
*658. Find K Closest Elements (H-)
*4. Median of Two Sorted Arrays (H)
69. Sqrt(x) (E+)
*1901. Find a Peak Element II (H)
702. Search in a Sorted Array of Unknown Size (M-)
540. Single Element in a Sorted Array (M+)
*33. Search in Rotated Sorted Array (M+)
*81. Search in Rotated Sorted Array II (M+)
153. Find Minimum in Rotated Sorted Array (M)
*154. Find Minimum in Rotated Sorted Array II (M+)
240. Search a 2D Matrix II (M)
*222.Count Complete Tree Nodes (H-)
*302. Smallest Rectangle Enclosing Black Pixels (H-)
*475. Heaters(M+)
275. H-Index II (M)
*1095. Find in Mountain Array (M+)
1533. Find the Index of the Large Integer (M)
*2563. Count the Number of Fair Pairs (M+)
2300. Successful Pairs of Spells and Potions (E+)
-
search by value: final val must converge + we know how to change val
*410. Split Array Largest Sum (H)
1011. Capacity To Ship Packages Within D Days (M+)
*1102. Path With Maximum Minimum Value (M+)
1631. Path With Minimum Effort (M)
1283. Find the Smallest Divisor Given a Threshold (M)
1870. Minimum Speed to Arrive on Time (M)
1300. Sum of Mutated Array Closest to Target (M)
1482. Minimum Number of Days to Make m Bouquets (M)
1552. Magnetic Force Between Two Balls (M)
*2439. Minimize Maximum of Array (M+)
-
kth element
378. Kth Smallest Element in a Sorted Matrix (M+)
*287. Find the Duplicate Number (M+)
*1060. Missing Element in Sorted Array (H)
1539. Kth Missing Positive Number (M)
*373. Find K Pairs with Smallest Sums (H-)
*2040. Kth Smallest Product of Two Sorted Arrays (H)
*1918. Kth Smallest Subarray Sum (H-)
719. Find K-th Smallest Pair Distance (M+)
668. Kth Smallest Number in Multiplication Table (M+)
-
11. Container With Most Water (M-)
167. Two Sum II - Input Array Is Sorted (E)
633. Sum of Square Numbers (M)
15. 3Sum (M)
16. 3Sum Closest (M-)
923. 3Sum With Multiplicity (H)
30. Substring with Concatenation of All Words
26. Remove Duplicates from Sorted Array
80. Remove Duplicates from Sorted Array II
524. Longest Word in Dictionary through Deleting
283. Move Zeroes (M-)
713. Subarray Product Less Than K
1234. Replace the Substring for Balanced String
1498. Number of Subsequences That Satisfy the Given Sum Condition
1574. Shortest Subarray to be Removed to Make Array Sorted
142. Linked List Cycle II (H-)
360. Sort Transformed Array (H-)
611. Valid Triangle Number (M+)
75. Sort Colors (M-)
1570. Dot Product of Two Sparse Vectors (E+)
1580. Put Boxes Into the Warehouse II
1687. Delivering Boxes from Storage to Ports
1989. Maximum Number of People That Can Be Caught in Tag
2422. Merge Operations to Turn Array Into a Palindrome
2354. Number of Excellent Pairs (H-)
2215. Find the Difference of Two Arrays (M-)
-
Sliding Windows
guan神:一边指针正常移动,另一边指针伺机而动
209. Minimum Size Subarray Sum (M)
1446. Consecutive Characters (E+)
3. Longest Substring Without Repeating Characters (M)
159. Longest Substring with At Most Two Distinct Characters (M+)
340. Longest Substring with At Most K Distinct Characters (M+)
395. Longest Substring with At Least K Repeating Characters (H)
424. Longest Repeating Character Replacement (M+)
76. Minimum Window Substring (H)
992. Subarrays with K Different Integers (H+)
2461. Maximum Sum of Distinct Subarrays With Length K
1248. Count Number of Nice Subarrays (H)
1004. Max Consecutive Ones III (M-)
1052. Grumpy Bookstore Owner (M)
*438. Find All Anagrams in a String (M)
1358. Number of Substrings Containing All Three Characters
1234. Replace the Substring for Balanced String
862. Shortest Subarray with Sum at Least K
1838. Frequency of the Most Frequent Element
2009. Minimum Number of Operations to Make Array Continuous
2024. Maximize the Confusion of an Exam
2106. Maximum Fruits Harvested After at Most K Steps
2537. Count the Number of Good Subarrays
-
Two pointers for two seuqences
986. Interval List Intersections
1577. Number of Ways Where Square of Number Is Equal to Product of Two Numbers
*92. Reverse Linked List II (M)
*25. Reverse Nodes in k-Group (M+)
*2074. Reverse Nodes in Even Length Groups (H-)
2. Add Two Numbers (M-)
21. Merge Two Sorted Lists (E-)
160. Intersection of Two Linked Lists (M)
234. Palindrome Linked List (M)
203. Remove Linked List Elements (E-)
83. Remove Duplicates from Sorted List (E)
82. Remove Duplicates from Sorted List II (M)
19. Remove Nth Node From End of List (M-)
*328. odd even linked list (M+)
*1171. Remove Zero Sum Consecutive Nodes from Linked List (H-)
876. Middle of the Linked List (E)
138. Copy List with Random Pointer
369. Plus One Linked List (M-)
430. Flatten a Multilevel Doubly Linked List
1721. Swapping Nodes in a Linked List (M+)
382. Linked List Random Node (E+)
100. Same Tree (E)
104. Maximum Depth of Binary Tree (E)
*110. Balanced Binary Tree (M-)
101. Symmetric Tree (M-)
*543. Diameter of Binary Tree (M-)
112. Path Sum (E+)
113. Path Sum II (M)
*437. Path Sum III (H-)
1110. Delete Nodes And Return Forest (M)
617. Merge Two Binary Trees (M-)
572. Subtree of Another Tree (M)
508. Most Frequent Subtree Sum (M-)
*250. Count Univalue Subtrees (M)
951. Flip Equivalent Binary Trees (M)
366. Find Leaves of Binary Tree (M-)
*834. Sum of Distances in Tree (H)
*1443. Minimum Time to Collect All Apples in a Tree (M+)
2477. Minimum Fuel Cost to Report to the Capital (M)
*427. Construct Quad Tree (M-)
742. Closest Leaf in a Binary Tree
298. Binary Tree Longest Consecutive Sequence
919. Complete Binary Tree Inserter
1161. Maximum Level Sum of a Binary Tree
662. Maximum Width of Binary Tree
979. Distribute Coins in Binary Tree
-
level order traversal
102. Binary Tree Level Order Traversal (M-)
103. Binary Tree Zigzag Level Order Traversal (M-)
107. Binary Tree Level Order Traversal II (M-)
637. Average of Levels in Binary Tree (M-)
*958. Check Completeness of a Binary Tree (M)
*1245. Tree Diameter (H+)
*314. Binary Tree Vertical Order Traversal (M+)
513. Find Bottom Left Tree Value (M)
199. Binary Tree Right Side View (M)
-
other traversals
*144. Binary Tree Preorder Traversal itr (M-)
*94. Binary Tree Inorder Traversal itr (M)
*145. Binary Tree Postorder Traversal itr (M-)
-
Serialize and Construct
*297. Serialize and Deserialize Binary Tree (M+)
*428. Serialize and Deserialize N-ary Tree (H)
*449. Serialize and Deserialize BST (H)
1008. Construct Binary Search Tree from Preorder Traversal (M)
*105. Construct Binary Tree from Preorder and Inorder Traversal (M+)
106. Construct Binary Tree from Inorder and Postorder Traversal (M+)
*889. Construct Binary Tree from Preorder and Postorder Traversal (H)
*536. Construct Binary Tree from String (H-)
*426. Convert Binary Search Tree to Sorted Doubly Linked List (M)
*652. Find Duplicate Subtrees (H-)
-
BST
700. Search in a Binary Search Tree (E-)
270. Closest Binary Search Tree Value (M-)
*450. Delete Node in a BST (M+)
*98. Validate Binary Search Tree (M)
*173. Binary Search Tree Iterator (M+)
*99. Recover Binary Search Tree (M+)
*108. Convert Sorted Array to Binary Search Tree (M-)
1382. Balance a Binary Search Tree (M)
*96. Unique Binary Search Trees (M+)
*95. Unique Binary Search Trees II (H)
*669. Trim a Binary Search Tree (M-)
538/1038. Convert BST to Greater Tree (M)
*897. Increasing Order Search Tree (M+)
501. Find Mode in Binary Search Tree
230. Kth Smallest Element in a BST (M-)
*1586. Binary Search Tree Iterator II (H)
530/783. Minimum Absolute Difference in BST (E+)
-
LCA
*235. Lowest Common Ancestor of a Binary Search Tree (E+)
*236. Lowest Common Ancestor of a Binary Tree (M)
*1644. Lowest Common Ancestor of a Binary Tree II (M)
1650. Lowest Common Ancestor of a Binary Tree III (M)
*1676. Lowest Common Ancestor of a Binary Tree IV (M+)
*865/1123. Smallest Subtree with all the Deepest Nodes (M+)
1740. Find Distance in a Binary Tree
*2096. Step-By-Step Directions From a Binary Tree Node to Another (M+)
-
Path in Tree
-
信息传递
1448. Count Good Nodes in Binary Tree
*124. Binary Tree Maximum Path Sum (M+)
1339. Maximum Product of Splitted Binary Tree (M)
1372. Longest ZigZag Path in a Binary Tree
549. Binary Tree Longest Consecutive Sequence II
*1519. Number of Nodes in the Sub-Tree With the Same Label (M)
*127. Word Ladder (H-)
490. The Maze (M)
994. Rotting Oranges (M+)
*1162. As Far from Land as Possible (M+)
*529. Minesweeper (M+)
339. Nested List Weight Sum (M-)
1091. Shortest Path in Binary Matrix (M+)
*675. Cut Off Trees for Golf Event (M+)
*1293. Shortest Path in a Grid with Obstacles Elimination (H)
*785. Is Graph Bipartite? (M+)
815. Bus Routes (H-)
1311. Get Watched Videos by Your Friends (M)
*1345. Jump Game IV (H-)
1129. Shortest Path with Alternating Colors (M+)
1559. Detect Cycles in 2D Grid
928. Minimize Malware Spread II
**1263. Minimum Moves to Move a Box to Their Target Location (H++)
*433. Minimum Genetic Mutation (M)
-
拓扑排序
207. Course Schedule (M+)
2115. Find All Possible Recipes from Given Supplies (M)
*310. Minimum Height Trees (H-)
-
Dijkstra (BFS+PQ)
*505. The Maze II (H-)
*787. Cheapest Flights Within K Stops (H)
*547. Number of Provinces (M-)
*417. Pacific Atlantic Water Flow (M+)
*694. Number of Distinct Islands (H)
46. Permutations (M)
47. Permutations II (M+)
77. Combinations (M)
*37. Sudoku Solver (H-)
*51. N-Queens (H-)
39. Combination Sum (M-)
79. Word Search (M)
131. Palindrome Partitioning (M+)
1306. Jump Game III (M-)
*22. Generate Parentheses (M-)
*17. Letter Combinations of a Phone Number (M-)
*386. Lexicographical Numbers (M)
419. Battleships in a Board (M)
841. Keys and Rooms (M-)
797. All Paths From Source to Target (E)
*491. Non-decreasing Subsequences (M+)
*93. Restore IP Addresses (M+)
-
search in an array
78. Subsets (E+)
90. Subsets II (M)
301. Remove Invalid Parentheses
-
dfs + memo
337.House Robber III (H-)
547.friend circles/ number of provinces (M)
1971. Find if Path Exists in Graph (E+)
323. Number of Connected Components in an Undirected Graph (M-)
1061. Lexicographically Smallest Equivalent String (M)
*332. Reconstruct Itinerary (H)
*2359. Find Closest Node to Given Two Nodes (M)
2571. Minimum Operations to Reduce an Integer to 0 (M)
Dynamic Programming
746. Min Cost Climbing Stairs (E)
*823. Binary Trees With Factors (M+)
*221. Maximal Square (H-)
-
i-1时间序列型 (下一轮只取决于上一轮的状态)
198. House Robber (E+)
*123. Best Time to Buy and Sell Stock III (H)
309. Best Time to Buy and Sell Stock with Cooldown (M)
790. Domino and Tromino Tiling (H)
256. Paint House (M-)
487. Max Consecutive Ones II (M)
1186. Maximum Subarray Sum with One Deletion (M)
-
i-k时间序列型(这一轮的状态取决于之前某一轮, 要用搜索来找到这个 j = i-k)
*300. Longest Increasing Subsequence (M-)
368. Largest Divisible Subset (M+)
*1105. Filling Bookcase Shelves (H)
-
双序列型
*1143. Longest Common Subsequence (M-)
*1092. Shortest Common Supersequence (H)
72. Edit Distance (M+)
*115. Distinct Subsequences (H)
*727. Minimum Window Subsequence (H)
583. Delete Operation for Two Strings (M)
712. Minimum ASCII Delete Sum for Two Strings (M)
*1216. Valid Palindrome III (M+)
1312. Minimum Insertion Steps to Make a String Palindrome (M+)
-
分割k连续区间型 -> 第k个区间依赖于第k-1个区间
*1278. Palindrome Partitioning III (H)
*813. Largest Sum of Averages (H)
-
[i:j]范围区间型 -> 小区间转化为大区间
131. Palindrome Partitioning (M+)
*516. Longest Palindromic Subsequence (M+)
*375. Guess Number Higher or Lower II (H-)
**1000. Minimum Cost to Merge Stones (H+)
1547. Minimum Cost to Cut a Stick
1130. Minimum Cost Tree From Leaf Values
-
背包问题
*416. Partition Equal Subset Sum (M+)
*494. Target Sum (H-)
*1049. Last Stone Weight II (H-)
322. Coin Change (E+)
*518. Coin Change II (M+)
-
迷宫型
120. Triangle (E+)
*174. Dungeon Game (M+)
*576. Out of Boundary Paths (H)
-
键盘型
-
状态压缩
*2572. Count the Number of Square-Free Subsets (H)
-
Kadane's Algorithm
*152.Maximum Product Subarray (M+)
*918. Maximum Sum Circular Subarray (H-)
1480. Running Sum of 1d Array (E-)
*560. Subarray Sum Equals K (M+)
*528. Random Pick with Weight (M+)
238. Product of Array Except Self
*974. Subarray Sums Divisible by K (M+)
*523. Continuous Subarray Sum (H-)
930. Binary Subarrays With Sum (M)
303. Range Sum Query - Immutable (E)
*304. Range Sum Query 2D - Immutable (M+)
*325. Maximum Size Subarray Sum Equals k (M+)
2256. Minimum Average Difference (E+)
*2389. Longest Subsequence With Limited Sum (M+)
862. Shortest Subarray with Sum at Least K
363. Max Sum of Rectangle No Larger Than K
1124. Longest Well-Performing Interval
-
扫描线 / 差分数组
370. Range Addition (M+)
*1249. Minimum Remove to Make Valid Parentheses (M-)
232. Implement Queue using Stacks(E)
1047. Remove All Adjacent Duplicates In String (E)
-
monotonic stack
*496. Next Greater Element I (M)
*503. Next Greater Element II (M+)
1019. Next Greater Node In Linked List (M)
*316/1081. Remove Duplicate Letters (H)
402. Remove K Digits (M+)
*1673. Find the Most Competitive Subsequence (M+)
*84. Largest Rectangle in Histogram (H)
*1856. Maximum Subarray Min-Product (H+)
1762. Buildings With an Ocean View (M-)
-
parse expression
*71. Simplify Path (M+)
*227. Basic Calculator II (M+)
*772. Basic Calculator III (H)
703. Kth Largest Element in a Stream (M)
2512. Reward Top K Students (M)
632. Smallest Range Covering Elements from K Lists
1675. Minimize Deviation in Array
-
dual pq
-
sort+pq
502. IPO (M)
455. Assign Cookies (E+)
*55. Jump Game (M-)
*659. Split Array into Consecutive Subsequences (H-)
*280. Wiggle Sort (M+)
2178. Maximum Split of Positive Even Integers (M+)
*624. Maximum Distance in Arrays (M+)
*2271. Maximum White Tiles Covered by a Carpet (M+)
*665. Non-decreasing Array (M+)
*670. Maximum Swap (M+)
*517. Super Washing Machines (H+)
*2551. Put Marbles in Bags (H)
2279. Maximum Bags With Full Capacity of Rocks (E)
2214. Minimum Health to Beat Game (E+)
*881. Boats to Save People (M)
2244. Minimum Rounds to Complete All Tasks (E+)
1833. Maximum Ice Cream Bars (E)
-
pq
1606. Find Servers That Handled Most Number of Requests
-
sort
1996. The Number of Weak Characters in the Game
1509. Minimum Difference Between Largest and Smallest Value in Three Moves
-
indexing sort
*41. First Missing Positive (H)
268. Missing Number (M+)
-
Two-pass distribution
*135. Candy (M+)
-
Three-pass
334. Increasing Triplet Subsequence
-
State machine
-
Interval
sorted by start point: min num of intervals to cover the whole range
sorted by end point: max number of non-overlapping intervals
1. Two Sum (E)
170. Two Sum III - Data structure design (E)
49. Group Anagrams (M-)
*128. Longest Consecutive Sequence (H-)
594. Longest Harmonious Subsequence (M-)
*149. Max Points on a Line (M+)
*380. Insert Delete GetRandom O(1) (M-)
166. Fraction to Recurring Decimal (M+)
392. Is Subsequence (H-)
*792. Number of Matching Subsequences (H-)
244. Shortest Word Distance II (M-)
811. Subdomain Visit Count (M-)
*447. Number of Boomerangs (M-)
890. Find and Replace Pattern (E+)
939. Minimum Area Rectangle (M)
1074. Number of Submatrices That Sum to Target
2342. Max Sum of a Pair With Equal Sum of Digits (M-)
1338. Reduce Array Size to The Half (M-)
1055. Shortest Way to Form String (M)
345. Reverse Vowels of a String (M-)
2131. Longest Palindrome by Concatenating Two Letter Words (M-)
1704. Determine if String Halves Are Alike (E)
1657. Determine if Two Strings Are Close(M-)
290. Word Pattern (M-)
1032. Stream of char (M+)
204. Count Primes (M+)
1290. Convert Binary Number in a Linked List to Integer (E)
1217. Minimum Cost to Move Chips to The Same Position (M)
*48. Rotate Image (M+)
12. Integer to Roman (E+)
*1071. Greatest Common Divisor of Strings (M)
453. Minimum Moves to Equal Array Elements
462. Minimum Moves to Equal Array Elements II
- Add Two Integers (H+)
*844. Backspace String Compare (M+)
415. Add Strings (M-)
408. Valid Word Abbreviation (E)
242. Valid Anagram (E-)
647. Palindromic Substrings (M)
*696. Count Binary Substrings (M+)
*388. Longest Absolute File Path (H-)
*418. Sentence Screen Fitting (M+)
*423. Reconstruct Original Digits from English (H)
*616/758. Add Bold Tag in String (H-)
564. Find the Closest Palindrome
434. Number of Segments in a String (E)
953. Verifying an Alien Dictionary(E)
2259. Remove Digit From Number to Maximize Result (E+)
-
KMP
346. Moving Average from Data Stream (E)
380. Insert Delete GetRandom O(1) (M)
*381. Insert Delete GetRandom O(1) - Duplicates allowed (H)
*631. Design Excel Sum Formula (H)
*295. Find Median from Data Stream (M)
588. Design In-Memory File System
1656. Design an Ordered Stream
1396. Design Underground System
981. Time Based Key-Value Store
-
Linked List
*146. LRU Cache (M+)
*460. LFU Cache (H)
*493. Reverse Pairs (H-)
1228. Missing Number In Arithmetic Progression
1710. Maximum Units on a Truck
757. Set Intersection Size At Least Two
1356. Sort Integers by The Number of 1 Bits
581. Shortest Unsorted Continuous Subarray
*274. H-Index (M)
406. Queue Reconstruction by Height
826. Most Profit Assigning Work
1268. Search Suggestions System
1520. Maximum Number of Non-Overlapping Substrings
853. Car Fleet (M+)
*539. Minimum Time Difference (M-)
*899. Orderly Queue (H-)
*869. Reordered Power of 2 (M)
-
counting sort
-
Bucket Sort
-
Quick Select
75. Sort Colors (M-)
*347. Top K Frequent Elements (M+)
-
Indexing Sort
*54. Spiral Matrix (M+)
36. Valid Sudoku (E+)
*989. Add to Array-Form of Integer (M)
67. Add Binary (E+)
-
Count subarray based on element
*2444. Count Subarrays With Fixed Bounds (M+)
828. Count Unique Characters of All Substrings of a Given String
1498. Number of Subsequences That Satisfy the Given Sum Condition
1856. Maximum Subarray Min-Product
2262. Total Appeal of A String