- 1. Two Sum
hash table
- 11. Container With Most Water
- 15. 3Sum
sort
two pointers
- 48. Rotate Image
- 88. Merge Sorted Array
- 75. Sort Colors
- 78. Subsets
- 238. Product of Array Except Self
- 406. Queue Reconstruction by Height
- 495. Teemo Attacking
- 506. Relative Ranks
- 605. Can Place Flowers
- 621. Task Scheduler
Hash table
- 645. Set Mismatch
- 760. Find Anagram Mappings
- 867. Transpose Matrix
- 961. N-Repeated Element in Size 2N Array
- 977. Squares of a Sorted Array
- 1085. Sum of Digits in the Minimum Number
- 1122. Relative Sort Array
array index count
- 1133. Largest Unique Number
- 1200. Minimum Absolute Difference
- 1207. Unique Number of Occurrences
Hash table
- 1213. Intersection of Three Sorted Arrays
- 1252. Cells with Odd Values in a Matrix
- 1295. Find Numbers with Even Number of Digits
- 1299. Replace Elements with Greatest Element on Right Side
- 1304. Find N Unique Integers Sum up to Zero
- 1313. Decompress Run-Length Encoded List
- 1337. The K Weakest Rows in a Matrix
- 1347. Minimum Number of Steps to Make Two Strings Anagram
- 1351. Count Negative Numbers in a Sorted Matrix
- 1365. How Many Numbers Are Smaller Than the Current Number
- 1380. Lucky Numbers in a Matrix
- 1385. Find the Distance Value Between Two Arrays
- 1389. Create Target Array in the Given Order
- 1394. Find Lucky Integer in an Array
- 1395. Count Number of Teams
- 1431. Kids With the Greatest Number of Candies
- 1450. Number of Students Doing Homework at a Given Time
- 1460. Make Two Arrays Equal by Reversing Sub-arrays
- 1464. Maximum Product of Two Elements in an Array
- 1470. Shuffle the Array
- 1480. Running Sum of 1d Array
- 1512. Number of Good Pairs
- 1534. Count Good Triplets
blute force
- 13. Roman to Integer
- 49. Group Anagrams
- 125. Valid Palindrome
list[::-1]
reverse a list,==
can compare two list directly. - 246. Strobogrammatic Number [hash]
- 299. Bulls and Cows
hash table
- 394. Decode String
- 451. Sort Characters By Frequency [map, sorted]
- 1021. Remove Outermost Parentheses
use flag
- 1108. Defanging an IP Address
- 1119. Remove Vowels from a String
- 1160. Find Words That Can Be Formed by Characters
- 1165. Single-Row Keyboard
- 1180. Count Substrings with Only One Distinct Letter [math]
- 1221. Split a String in Balanced Strings
- 1309. Decrypt String from Alphabet to Integer Mapping
- 1370. Increasing Decreasing String
- 1436. Destination City
- 1496. Path Crossing
set
- 1528. Shuffle String
- 5. Longest Palindromic Substring
- 62. Unique Paths
- 64. Minimum Path Sum
- 96. Unique Binary Search Trees
- 121. Best Time to Buy and Sell Stock
- 122. Best Time to Buy and Sell Stock II
- 309. Best Time to Buy and Sell Stock with Cooldown
- 256. Paint House
- 337. House Robber III
- 1277. Count Square Submatrices with All Ones
- 202. Happy Number
- 258. Add Digits
digit root
- 507. Perfect Number
- 1103. Distribute Candies to People
- 1217. Minimum Cost to Move Chips to The Same Position
- 1232. Check If It Is a Straight Line
- 1281. Subtract the Product and Sum of Digits of an Integer
- 1323. Maximum 69 Number
- 1342. Number of Steps to Reduce a Number to Zero
- 1523. Count Odd Numbers in an Interval Range
- 116. Populating Next Right Pointers in Each Node
- 559. Maximum Depth of N-ary Tree
- 563. Binary Tree Tilt
- 589. N-ary Tree Preorder Traversal
- 590. N-ary Tree Postorder Traversal
- 1469. Find All The Lonely Nodes
- 1490. Clone N-ary Tree
- 108. Convert Sorted Array to Binary Search Tree
- 235. Lowest Common Ancestor of a Binary Search Tree
- 538. Convert BST to Greater Tree
- 653. Two Sum IV - Input is a BST
- 105. Construct Binary Tree from Preorder and Inorder Traversal [recursive]
- 112. Path Sum
depth first search
- 114. Flatten Binary Tree to Linked List
- 226. Invert Binary Tree [recursive]
- 437. Path Sum III
- 543. Diameter of Binary Tree
- 1008. Construct Binary Search Tree from Preorder Traversal [recursive]
- 1302. Deepest Leaves Sum
- 1315. Sum of Nodes with Even-Valued Grandparent
- 17. Letter Combinations of a Phone Number [iteration]
- 39. Combination Sum
- 46. Permutations
- 47. Permutations II [dfs]
- 77. Combinations
- 79. Word Search [dfs]
- 90. Subsets II [dfs], 95.36%
- 401. Binary Watch
- 784. Letter Case Permutation
- 1079. Letter Tile Possibilities [dfs]
- 155. Min Stack
- 1047. Remove All Adjacent Duplicates In String
- 1063. Number of Valid Subarrays
- 1441. Build an Array With Stack Operations
- 24. Swap Nodes in Pairs
recursion
add one leading node
- 61. Rotate List
take remainder to get actual rotate number
- 86. Partition List
- 92. Reverse Linked List II
- 141. Linked List Cycle
- 142. Linked List Cycle II
- 148. Sort List
- 160. Intersection of Two Linked Lists
- 234. Palindrome Linked List : use fast-slow pointers, can get the middle position of the linked list
- 237. Delete Node in a Linked List
- 1265. Print Immutable Linked List in Reverse
- 1290. Convert Binary Number in a Linked List to Integer
- 1474. Delete N Nodes After M Nodes of a Linked List
- 76. * Minimum Window Substring
- 239. Sliding Window Maximum
monotonic queue
- 346. Moving Average from Data Stream
- 567. Permutation in String [hash]
- 33. Search in Rotated Sorted Array
- 153. Find Minimum in Rotated Sorted Array
- 278. First Bad Version
- 1064. Fixed Point