- Published on
An overview of LeetCode question types and solutions
- Authors
- Author
- Hang DONG
Index
Types of LeetCode Questions
- Math
- Arrays and Strings
- Basic Operations (e.g., Two Sum, Reverse String)
- Subarray/Substring Problems (e.g., Maximum Subarray, Longest Substring Without Repeating Characters)
- Linked Lists
- Basic Operations (e.g., Add Two Numbers, Merge Two Sorted Lists)
- Advanced Problems (e.g., Reverse Linked List, Remove Nth Node From End of List)
- Trees
- Traversal Problems (e.g., Preorder Traversal, Inorder Traversal)
- Binary Search Trees (e.g., Validate Binary Search Tree, Lowest Common Ancestor)
- Dynamic Programming
- Climbing stairs
- Knapsack Problems (e.g., 0/1 Knapsack, Coin Change)
- Longest Common Subsequence, Edit Distance
- Sorting and Searching
- Basic Sorting Algorithms (e.g., Merge Sort, Quick Sort)
- Searching Algorithms (e.g., Binary Search)
- Graphs
- Traversal Problems (e.g., Depth-First Search, Breadth-First Search)
- Shortest Path Problems (e.g., Dijkstra's Algorithm, Bellman-Ford Algorithm)
- Backtracking
- Subset Problems (e.g., Subsets, Combination Sum)
- Permutation Problems (e.g., Permutations, N-Queens)
- Bit Manipulation
- Basic Operations (e.g., Bitwise AND, Bitwise XOR)
- Counting Set Bits, Gray Code
Approaches and Solutions
- Brutal Force Approach
- Optimized Approaches
- Two-Pointer Technique
- Sliding Window Technique
- Dynamic Programming
- Divide and Conquer
- Greedy Approach
- Backtracking
- Recursion
- Common Data Structures
Utilize appropriate data structures such as arrays, linked lists, trees, graphs, and hash tables based on problem requirements.
Tips for LeetCode preparation
- Recognize common problem-solving patterns and apply them appropriately.
- Reading others' solutions to gain some insights.
- Mock interview. Simulate real interview scenarios and improve problem-solving under pressure.