LeetCode Solutions

This LeetCode Solutions column contains algorithm problem solutions, including clear problem analysis, multi-language implementations (Python/Go), and complexity analysis to help you efficiently prepare for algorithm interviews.

Problem Categories

Easy

Foundational algorithm problems for beginners to practice and reinforce core concepts.

#Problem#Problem
12Integer to Roman26Remove Duplicates from Sorted Array
28Implement strStr()34Find First and Last Position of Element in Sorted Array
36Valid Sudoku50Pow(x, n) - Implement pow function
60Permutation Sequence75Sort Colors - Dutch National Flag
89Gray Code112Path Sum
152Maximum Product Subarray162Find Peak Element
165Compare Version Numbers168Excel Sheet Column Title
172Factorial Trailing Zeroes173Binary Search Tree Iterator
202Happy Number204Count Primes
205Isomorphic Strings413Arithmetic Slices
437Path Sum III451Sort Characters By Frequency
503Next Greater Element II567Permutation in String
647Palindromic Substrings859Buddy Strings
969Pancake Sorting970Powerful Integers
971Flip Binary Tree To Match Preorder Traversal977Squares of a Sorted Array
985Sum of Even Numbers After Queries989Add to Array-Form of Integer
997Find the Town Judge1002Find Common Characters
1004Max Consecutive Ones III1018Binary Prefix Divisible By 5
1078Occurrences After Bigram636Exclusive Time of Functions
-String to Integer (atoi)-String Reverse
-Matrix Rotation

Medium

Classic interview questions worth revisiting and practicing systematically.

CategoryProblem Link
Binary TreeConstruct Binary Tree Series
Populating Next Right Pointers in Each Node
Binary Tree and Linked List专题
Validate Binary Search Tree
Lowest Common Ancestor of a Binary Tree
Convert Sorted List to Binary Search Tree
Balanced Binary Tree
Unique Binary Search Trees
Unique Binary Search Trees II
Flip Binary Tree To Match Preorder Traversal
Dynamic ProgrammingDecode Ways Series
Word Break Series
Best Time to Buy and Sell Stock
Minimum Cost For Tickets
Power of Series
Unique Binary Search Trees
BacktrackingCombination Sum Series
Palindrome Partitioning
Letter Tile Possibilities
Linked ListLRU Cache
Binary SearchSearch in Rotated Sorted Array
Bit ManipulationSingle Number Series
Counting Bits
Bitwise AND of Numbers Range
Reverse Bits
Sum of Two Integers
Divide Two Integers
Sliding WindowLongest Substring Without Repeating Characters
Minimum ASCII Delete Sum for Two Strings
Other Classics3Sum
Gas Station
Candy
Kth Largest Element in an Array
Two City Scheduling
Video Stitching
Divisor Game
Stone Game
Longest Univalue Path
Remove Sub-Folders from the Filesystem
Queries on a Permutation With Key
Capacity To Ship Packages Within D Days
Maximum Sum of Two Non-Overlapping Subarrays
Insufficient Nodes in Root to Leaf Paths
Smallest Subsequence of Distinct Characters
Word Ladder Series

Hard

Advanced algorithm challenges for deeper understanding and problem-solving skills.

ProblemLink
37Sudoku Solver
952Largest Component Size by Common Factor
-Regular Expression Matching

General Techniques

Universal problem-solving methods and templates across different problem types.

TechniqueLink
Common STL Operations常用 STL 操作
Sliding Window专题Sliding Window专题

Core Topics

  • Sliding Window - Two-pointer technique for efficient subarray/substring problems
  • Binary Search - Efficient search strategy for sorted data
  • Dynamic Programming - Optimal substructure problem decomposition
  • DFS/BFS - Tree and graph traversal methods
  • Backtracking - Exhaustive search for finding all solutions
  • Bit Manipulation - Optimize space and time complexity using bit operations

Each solution includes clear problem analysis, multi-language code implementations, and complexity analysis. Practice systematically by problem type for best results.