Leetcode Patterns
Leetcode Patterns
1. Two Sum, 11. Container With Most Water, 15. 3Sum, 16. 3Sum Closest, 18. 4Sum, 167. Two Sum II - Input Array Is Sorted,
141. Linked List Cycle, 202. Happy Number, 287. Find the Duplicate Number
19. Remove Nth Node From End of List, 876. Middle of the Linked List, 2095. Delete the Middle Node of a Linked List
26. Remove Duplicates from Sorted Array, 27. Remove Element, 75. Sort Colors, 80. Remove Duplicates from Sorted Array II,
844. Backspace String Compare
5. Longest Palindromic Substring, 647. Palindromic Substrings
151. Reverse Words in a String, 344. Reverse String, 345. Reverse Vowels of a String, 541. Reverse String II
346. Moving Average from Data Stream, 643. Maximum Average Subarray I, 2985. Calculate Compressed Mean, 3254. Find th
3. Longest Substring Without Repeating Characters, 76. Minimum Window Substring, 209. Minimum Size Subarray Sum, 219.
239. Sliding Window Maximum, 862. Shortest Subarray with Sum at Least K, 1696. Jump Game VI
438. Find All Anagrams in a String, 567. Permutation in String
102. Binary Tree Level Order Traversal, 103. Binary Tree Zigzag Level Order Traversal, 199. Binary Tree Right Side View, 515
100. Same Tree, 101. Symmetric Tree, 105. Construct Binary Tree from Preorder and Inorder Traversal, 114. Flatten Binary Tr
94. Binary Tree Inorder Traversal, 98. Validate Binary Search Tree, 173. Binary Search Tree Iterator, 230. Kth Smallest Elemen
104. Maximum Depth of Binary Tree, 110. Balanced Binary Tree, 124. Binary Tree Maximum Path Sum, 145. Binary Tree Posto
235. Lowest Common Ancestor of a Binary Search Tree, 236. Lowest Common Ancestor of a Binary Tree
297. Serialize and Deserialize Binary Tree, 572. Subtree of Another Tree, 652. Find Duplicate Subtrees
130. Surrounded Regions, 200. Number of Islands, 417. Pacific Atlantic Water Flow, 547. Number of Provinces, 695. Max Area
127. Word Ladder, 542. 01 Matrix, 994. Rotting Oranges, 1091. Shortest Path in Binary Matrix
207. Course Schedule, 210. Course Schedule II, 802. Find Eventual Safe States, 1059. All Paths from Source Lead to Destinat
207. Course Schedule, 210. Course Schedule II, 269. Alien Dictionary, 310. Minimum Height Trees, 444. Sequence Reconstruc
133. Clone Graph
743. Network Delay Time, 778. Swim in Rising Water, 1514. Path with Maximum Probability, 1631. Path With Minimum Effort, 1
787. Cheapest Flights Within K Stops
200. Number of Islands, 261. Graph Valid Tree, 305. Number of Islands II, 323. Number of Connected Components in an Undir
70. Climbing Stairs, 91. Decode Ways, 198. House Robber, 213. House Robber II, 337. House Robber III, 509. Fibonacci Num
53. Maximum Subarray
322. Coin Change, 377. Combination Sum IV, 518. Coin Change II
416. Partition Equal Subset Sum, 494. Target Sum
139. Word Break, 140. Word Break II
583. Delete Operation for Two Strings, 1143. Longest Common Subsequence
72. Edit Distance
62. Unique Paths, 63. Unique Paths II, 64. Minimum Path Sum, 120. Triangle, 221. Maximal Square, 931. Minimum Falling Pat
312. Burst Balloons, 546. Remove Boxes
95. Unique Binary Search Trees II, 96. Unique Binary Search Trees, 241. Different Ways to Add Parentheses
300. Longest Increasing Subsequence, 354. Russian Doll Envelopes, 1671. Minimum Number of Removals to Make Mountain
215. Kth Largest Element in an Array, 347. Top K Frequent Elements, 451. Sort Characters By Frequency, 506. Relative Ranks
295. Find Median from Data Stream, 1825. Finding MK Average
23. Merge k Sorted Lists, 373. Find K Pairs with Smallest Sums, 378. Kth Smallest Element in a Sorted Matrix, 632. Smallest R
253. Meeting Rooms II, 767. Reorganize String, 857. Minimum Cost to Hire K Workers, 1642. Furthest Building You Can Reach
17. Letter Combinations of a Phone Number, 77. Combinations, 78. Subsets, 90. Subsets II
31. Next Permutation, 46. Permutations, 60. Permutation Sequence
39. Combination Sum, 40. Combination Sum II
22. Generate Parentheses, 301. Remove Invalid Parentheses
79. Word Search, 212. Word Search II, 2018. Check if Word Can Be Placed In Crossword
37. Sudoku Solver, 51. N-Queens
131. Palindrome Partitioning
56. Merge Intervals, 57. Insert Interval, 759. Employee Free Time, 986. Interval List Intersections, 2406. Divide Intervals Into M
45. Jump Game II, 55. Jump Game
121. Best Time to Buy and Sell Stock, 122. Best Time to Buy and Sell Stock II
134. Gas Station
621. Task Scheduler
35. Search Insert Position, 69. Sqrt(x), 74. Search a 2D Matrix, 278. First Bad Version, 374. Guess Number Higher or Lower, 5
33. Search in Rotated Sorted Array, 81. Search in Rotated Sorted Array II, 153. Find Minimum in Rotated Sorted Array, 5 162.
410. Split Array Largest Sum, 774. Minimize Max Distance to Gas Station, 875. Koko Eating Bananas, 1011. Capacity To Ship
34. Find First and Last Position of Element in Sorted Array, 658. Find K Closest Elements
4. Median of Two Sorted Arrays
20. Valid Parentheses, 32. Longest Valid Parentheses, 921. Minimum Add to Make Parentheses Valid, 1249. Minimum Remov
402. Remove K Digits, 496. Next Greater Element I, 503. Next Greater Element II, 739. Daily Temperatures, 901. Online Stock
150. Evaluate Reverse Polish Notation, 224. Basic Calculator, 227. Basic Calculator II, 772. Basic Calculator III
71. Simplify Path, 394. Decode String, 735. Asteroid Collision
155. Min Stack
84. Largest Rectangle in Histogram, 85. Maximal Rectangle
136. Single Number, 137. Single Number II, 268. Missing Number, 389. Find the Difference
191. Number of 1 Bits
338. Counting Bits
231. Power of Two, 342. Power of Four
83. Remove Duplicates from Sorted List, 92. Reverse Linked List II, 206. Reverse Linked List, 25. Reverse Nodes in k-Group, 2
21. Merge Two Sorted Lists
2. Add Two Numbers, 369. Plus One Linked List
160. Intersection of Two Linked Lists
24. Swap Nodes in Pairs, 61. Rotate List, 86. Partition List, 143. Reorder List, 328. Odd Even Linked List
48. Rotate Image, 189. Rotate Array
54. Spiral Matrix, 885. Spiral Matrix III, 2326. Spiral Matrix IV
73. Set Matrix Zeroes
238. Product of Array Except Self
66. Plus One
88. Merge Sorted Array
41. First Missing Positive, 268. Missing Number, 287. Find the Duplicate Number, 442. Find All Duplicates in an Array, 448. Fin
152. Maximum Product Subarray
146. LRU Cache, 155. Min Stack, 208. Implement Trie (Prefix Tree), 211. Design Add and Search Words Data Structure, 225. I
m II - Input Array Is Sorted, 349. Intersection of Two Arrays, 392. Is Subsequence, 881. Boats to Save People, 977. Squares of a Sorted A
de of a Linked List
icates from Sorted Array II, 283. Move Zeroes, 443. String Compression, 905. Sort Array By Parity, 2337. Move Pieces to Obtain a String, 2
pressed Mean, 3254. Find the Power of K-Size Subarrays I, 3318. Find X-Sum of All K-Long Subarrays I
m Size Subarray Sum, 219. Contains Duplicate II, 424. Longest Repeating Character Replacement, 713. Subarray Product Less Than K, 90
y Tree Right Side View, 515. Find Largest Value in Each Tree Row, 1161. Maximum Level Sum of a Binary Tree
ersal, 114. Flatten Binary Tree to Linked List, 226. Invert Binary Tree, 257. Binary Tree Paths, 988. Smallest String Starting From Leaf
or, 230. Kth Smallest Element in a BST, 501. Find Mode in Binary Search Tree, 530. Minimum Absolute Difference in BST
Sum, 145. Binary Tree Postorder Traversal, 337. House Robber III, 366. Find Leaves of Binary Tree, 543. Diameter of Binary Tree, 863. All
of Provinces, 695. Max Area of Island, 733. Flood Fill, 841. Keys and Rooms, 1020. Number of Enclaves, 1254. Number of Closed Islands,
Path With Minimum Effort, 1976. Number of Ways to Arrive at Destination, 2045. Second Minimum Time to Reach Destination, 2203. Minim
ed Components in an Undirected Graph, 3 547. Number of Provinces, 684. Redundant Connection, 4 721. Accounts Merge, 737. Sentenc
ber III, 509. Fibonacci Number, 740. Delete and Earn, 746. Min Cost Climbing Stairs
e, 931. Minimum Falling Path Sum, 1277. Count Square Submatrices with All Ones
Number Higher or Lower, 540. Single Element in a Sorted Array, 704. Binary Search, 1539. Kth Missing Positive Number
otated Sorted Array, 5 162. Find Peak Element, 852. Peak Index in a Mountain Array, 1095. Find in Mountain Array
as, 1011. Capacity To Ship Packages 6 Within D Days, 1482. Minimum Number of Days to Make m Bouquets, 1760. Minimum Limit of Bal
alid, 1249. Minimum Remove to Make Valid Parentheses, 1963. Minimum Number of Swaps to Make the String Balanced
eratures, 901. Online Stock Span, 907. Sum of Subarray Minimums, 962. Maximum Width Ramp, 1475. Final Prices With a Special Discou
Calculator III
Reverse Nodes in k-Group, 234. Palindrome Linked List, 82. Remove Duplicates from Sorted List II
licates in an Array, 448. Find All Numbers Disappeared in an Array
ing Match, 796. Rotate String, 3008. Find Beautiful Indices in the Given Array II
Words Data Structure, 225. Implement Stack using Queues, 232. Implement Queue using Stacks, 251. Flatten 2D Vector, 271. Encode and
977. Squares of a Sorted Array, 259. 3Sum Smaller
ay Product Less Than K, 904. Fruit Into Baskets, 1004. Max Consecutive Ones III, 1438. Longest Continuous Subarray With Absolute Diff
eter of Binary Tree, 863. All Nodes Distance K in Binary Tree, 1110. Delete Nodes And Return Forest, 2458. Height of Binary Tree After Su
Number of Closed Islands, 1905. Count Sub Islands, 2101. Detonate the Maximum Bombs
Parallel Courses III, 2115. Find All Possible Recipes from Given Supplies, 2392. Build a Matrix With Conditions
ach Destination, 2203. Minimum Weighted Subgraph With the Required Paths, 2290. Minimum Obstacle Removal to Reach Corner, 2577. M
counts Merge, 737. Sentence Similarity II, 947. Most Stones Removed with Same Row or Column, 952. Largest Component Size by Comm
Stone Weight, 2558. Take Gifts From the Richest Pile
1760. Minimum Limit of Balls in a Bag, 2064. Minimized Maximum of Products Distributed to Any Store, 2226. Maximum Candies Allocated
rices With a Special Discount in a Shop, 1673. Find the Most Competitive Subsequence
2D Vector, 271. Encode and Decode Strings, 295. Find Median from Data Stream, 341. Flatten Nested List Iterator, 346. Moving Average fr
Subarray With Absolute Diff Less Than or Equal to Limit, 1493. Longest Subarray of 1's After Deleting One Element, 1 1658. Minimum Ope
val to Reach Corner, 2577. Minimum Time to Visit a Cell In a Grid, 2812. Find the Safest Path in a Grid
t Component Size by Common Factor, 959. Regions Cut By Slashes, 1101. The Earliest Moment When Everyone Become Friends
Maximum Candies Allocated to K Children
ator, 346. Moving Average from Data Stream, 353. Design Snake Game, 359. Logger Rate Limiter, 362. Design Hit Counter, 379. Design Ph
ment, 1 1658. Minimum Operations to Reduce X to Zero, 1838. Frequency of the Most Frequent Element, 2461. Maximum Sum of Distinct S
ne Become Friends
Hit Counter, 379. Design Phone Directory, 380. Insert Delete GetRandom O(1), 432. All O`one Data Structure, 460. LFU Cache, 604. Desi
Maximum Sum of Distinct Subarrays With Length K, 2516. Take K of Each Character From Left and Right, 2762. Continuous Subarrays, 2
460. LFU Cache, 604. Design Compressed String Iterator, 622. Design Circular Queue, 641. Design Circular Deque, 642. Design Search A
2. Continuous Subarrays, 2779. Maximum Beauty of an Array After Applying Operation, 2981. Find Longest Special Substring That Occurs
eque, 642. Design Search Autocomplete System, 706. Design HashMap, 715. Range Module, 900. RLE Iterator, 981. Time Based Key-Va
ecial Substring That Occurs Thrice I, 3026. Maximum Good Subarray Sum, 3346. Maximum Frequency of an Element After Performing Op
r, 981. Time Based Key-Value Store, 1146. Snapshot Array, 1348. Tweet Counts Per Frequency, 1352. Product of the Last K Numbers, 13
lement After Performing Operations I, 3347. Maximum Frequency of an Element After Performing Operations II 2
ct of the Last K Numbers, 1381. Design a Stack With Increment Operation, 1756. Design Most Recently Used Queue, 2013. Detect Squares
ueue, 2013. Detect Squares, 2034. Stock Price Fluctuation, 2296. Design a Text Editor, 2336. Smallest Number in Infinite Set
r in Infinite Set