Leetcode | Master Guide

Notes leetcode problem

Reference: leetcode-master, Python-LeetCode 581 從基礎的 Array 到 Dynamic Programming 都有詳細的解釋。

1. Array

Easy Array
35. Search Insert Position
34. Find First and Last Position of Element in Sorted Array
69. Sqrt(x)
367. Valid Perfect Square
27. Remove Element
26. Remove Duplicates from Sorted Array
80. Remove Duplicates from Sorted Array II
283. Move Zeroes
844. Backspace String Compare
977. Squares of a Sorted Array
4. Median of Two Sorted Arrays
Spiral Matrix
209. Minimum Size Subarray Sum
3. Longest Substring Without Repeating Characters
287. Find the Duplicate Number
57. Insert Interval
1995. Count Special Quadruplets

704. Binary search
33. Search in Rotated Sorted Array
2601. Prime Subtraction Operation
2070. Most Beautiful Item for Each Query

Sliding Window

3. Longest Substring Without Repeating Characters
395. Longest Substring with At Least K Repeating Characters
2958. Length of Longest Subarray With at Most K Frequency
713. Subarray Product Less Than K
992. Subarrays with K Different Integers
2444. Count Subarrays With Fixed Bounds
2461. Maximum Sum of Distinct Subarrays With Length K
3254. Find the Power of K-Size Subarrays I

Matrix

861. Score After Flipping Matrix
36. Valid Sudoku

Prefix Sum

525. Contiguous Array
974. Subarray Sums Divisible by K

Sort

75. Sort Colors
1051. Height Checker
1122. Relative Sort Array
2037. Minimum Number of Moves to Seat Everyone
945. Minimum Increment to Make Array Unique
2233. Maximum Product After K Increments
1508. Range Sum of Sorted Subarray Sums


2. String

Most string problems are handled similarly to arrays.

Easy String 344. Reverse String
541. Reverse String II
151. Reverse Words in a String
28. Find the Index of the First Occurrence in a String
459. Repeated Substring Pattern
String Summarize
71. Simplify Path
72. Edit Distance
1653. Minimum Deletions to Make String Balanced
539. Minimum Time Difference

Trie

14. Longest Common Prefix


3. Linkedlist

203. Remove Linked List Elements
707. Design Linked List
206. Reverse Linked List
24. Swap Nodes in Pairs
160. Intersection of Two Linked Lists
141. Linked List Cycle
142. Linked List Cycle II
21. Merge Two Sorted Lists
23. Merge k Sorted Lists
25. Reverse Nodes in k-Group
83. Remove Duplicates from Sorted List
143. Reorder List
Linkedlist Summarize
2816. Double a Number Represented as a Linked List
2181. Merge Nodes in Between Zeros
2058. Find the Minimum and Maximum Number of Nodes Between Critical Points
725. Split Linked List in Parts
2807. Insert Greatest Common Divisors in Linked List

Two Pointers of Linkedlist

Middle Node of Linkedlist
19. Remove Nth Node From End of List
1721. Swapping Nodes in a Linked List


4. Hash

242. Valid Anagram
2395. Find Subarrays With Equal Sum
1002. Find Common Characters
349. Intersection of Two Arrays
202. Happy Number
454. 4Sum II
383. Ransom Note
15. 3Sum (Hash)
18. 4Sum (Hash)
459. Repeated Substring Pattern
268. Missing Number
41. First Missing Positive
1481. Least Number of Unique Integers after K Removals
128. Longest Consecutive Sequence
791. Custom Sort String
506. Relative Ranks


5. Two Pointer

1365. How Many Numbers Are Smaller Than the Current Number
125. Valid Palindrome
5. Longest Palindromic Substring
15. 3Sum (E)
18. 4Sum (E)
42. Trapping Rain Water
2149. Rearrange Array Elements by Sign
1750. Minimum Length of String After Deleting Similar Ends
442. Find All Duplicates in an Array 881. Boats to Save People
1395. Count Number of Teams
845. Longest Mountain in Array


6. Queue & Stack

232. Implement Queue using Stacks
225. Implement Stack using Queues
20. Valid Parentheses
1047. Remove All Adjacent Duplicates In String
150. Evaluate Reverse Polish Notation
239. Sliding Window Maximum
347. Top K Frequent Elements
Stack&Queue Summarize
1249. Minimum Remove to Make Valid Parentheses
1700. Number of Students Unable to Eat Lunch
950. Reveal Cards In Increasing Order
1190. Reverse Substrings Between Each Pair of Parentheses
1717. Maximum Score From Removing Substrings
735. Asteroid Collision
921. Minimum Add to Make Parentheses Valid

Priority Queue

1046. Last Stone Weight
1642. Furthest Building You Can Reach
502. IPO
703. Kth Largest Element in a Stream
2530. Maximal Score After Applying K Operations


7. Binary Tree

Build Binary Tree for Array
Recursion Binary Tree Traversal
Iteration Binary Tree Traversal
Iteration Binary Trees Unified Method
Binary Tree Level Order Traversal
N-ary Tree Traversal
226. Invert Binary Tree
559. Maximum Depth of N-ary Tree
783. Minimum Distance Between BST Nodes
Binary Tree Summarize 1
100. Same Tree
572. Subtree of Another Tree
101. Symmetric Tree
222. Count Complete Tree Nodes
513. Find Bottom Left Tree Value
110. Balanced Binary Tree
257. Binary Tree Paths
112. Path Sum & II & III
Binary Tree Summarize 2
1325. Delete Leaves With a Given Value
1038. Binary Search Tree to Greater Sum Tree
2196. Create Binary Tree From Descriptions
2096. Step-By-Step Directions From a Binary Tree Node to Another
1530. Number of Good Leaf Nodes Pairs
1367. Linked List in Binary Tree

Other Operations

623. Add One Row to Tree
979. Distribute Coins in Binary Tree


8. Backtracking

77. Combinations
79. Word Search
17. Letter Combinations of a Phone Number
39. Combination Sum I & II & III
22. Generate Parentheses
Backtracking Summarize
131. Palindrome Partitioning
93. Restore IP Addresses
78. Subsets
Backtracking Summarize 2
51. N-Queens
52. N-Queens II
979. Distribute Coins in Binary Tree
37. Sudoku Solver
46. Permutations
2597. The Number of Beautiful Subsets
1255. Maximum Score Words Formed by Letters


9. Greedy Algorithm

55. Jump Game I & II
452. Minimum Number of Arrows to Burst Balloons
455. Assign Cookies
948. Bag of Tokens
621. Task Scheduler
334. Increasing Triplet Subsequence
1509. Minimum Difference Between Largest and Smallest Value in Three Moves


10. Math

43. Multiply Strings
976. Largest Perimeter Triangle
2971. Find Polygon With the Largest Perimeter
1518. Water Bottles


11. Dynamic Programming

509. Fibonacci Number
70. Climbing Stairs
746. Min Cost Climbing Stairs
62. Unique Paths
343. Integer Break
96. Unique Binary Search Trees
300. Longest Increasing Subsequence
2370. Longest Ideal Subsequence
Minimum Falling Path Sum I & II
32. Longest Valid Parentheses
1105. Filling Bookcase Shelves
2684. Maximum Number of Moves in a Grid

0/1 Knapsack Problem

416. Partition Equal Subset Sum
1049. Last Stone Weight II
494. Target Sum
474. Ones and Zeroes

Unbounded Knapsack Problem

518. Coin Change II & I
377. Combination Sum IV
279. Perfect Squares
139. Word Break
140. Word Break II


12. Bit Manipulation

Bit Manipulation Summarize
201. Bitwise AND of Numbers Range


13. Graph

1971. Find if Path Exists in Graph
787. Cheapest Flights Within K Stops
2092. Find All People With Secret
514. Freedom Trail
2812. Find the Safest Path in a Grid
1791. Find Center of Star Graph
2497. Maximum Star Sum of a Graph
1382. Balance a Binary Search Tree
2285. Maximum Total Importance of Roads

200. Number of Islands
2368. Reachable Nodes With Restrictions
778. Swim in Rising Water
797. All Paths From Source to Target

752. Open the Lock
1654. Minimum Jumps to Reach Home
2045. Second Minimum Time to Reach Destination

Topological Sort

310. Minimum Height Trees
2192. All Ancestors of a Node in a Directed Acyclic Graph

Shortest Path

2976. Minimum Cost to Convert String I
743. Network Delay Time
1976. Number of Ways to Arrive at Destination


14. Other

1. Two sum
2. Add Two Numbers
7. Reverse Integer
11. Container With Most Water
13. Roman to Integer
16. 3Sum_Closest
49. Group Anagrams
50. Pow(x, n)
67. Add Binary
118. Pascal’s Triangle I & II
989. Add to Array-Form of Integer
1523. Count Odd Numbers in an Interval Range
1979. Find Greatest Common Divisor of Array

Last Edit

3-7-2024 17:30

results matching ""

    No results matching ""

    , leetcode, algorithm