力扣百大算法题精选【Hard 模式】Top 100 Liked LeetCode
“刷了300道题,面试还是被Hard题秒杀?” —— 这可能是许多LeetCode练习者的真实噩梦。当你自信满满地走进面试间,面试官却抛出一道《俄罗斯套娃信封》或《戳气球》,瞬间让你体会到什么叫"题目都看得懂,代码却无从下手"的绝望。
实不相瞒,博主在当年面试菊厂之前刷了大量Medium的题目和部分Hard的题目,面试时体感非常良好,可见平时练的难,考试就能考得好!
LeetCode 354. 俄罗斯套娃信封问题(Russian Doll Envelopes)
给定一个二维整数数组envelopes
,其中envelopes[i] = [w_i, h_i]
表示第i
个信封的宽度和高度。当一个信封的宽度和高度都比另一个信封大时,它可以套进去(类似俄罗斯套娃)。求最多能有多少个信封组成“套娃”序列?
⭐算法OJ⭐俄罗斯套娃信封问题【排序 + LIS】Russian Doll Envelopes
LeetCode 312. 戳气球(Burst Balloons)
给定n
个气球,编号从0
到n-1
,每个气球上标有一个数字nums[i]
。戳破气球 i 可以获得nums[left] * nums[i] * nums[right]
的硬币(left
和right
是i
的相邻气球)。戳破后,left
和right
变成相邻。求能获得的最大硬币数量。
⭐算法OJ⭐ 戳气球【动态规划】Burst Balloons
但别担心!这份LeetCode百大Hard题精选清单,正是破解顶级科技公司面试的"屠龙宝典"。
Why These Questions?
- 统计数据显示为高频面试考题
- 覆盖动态规划、图、树、系统设计等核心概念
- 存在复杂度 O ( n ) O(n) O(n) 或者 O ( l o g n ) O(log n) O(logn) 的解法
分类
数组&字符串(Arrays & Strings)
-
Median of Two Sorted Arrays (Binary Search)
-
Trapping Rain Water (Two Pointers/Dynamic Programming)
-
Longest Substring Without Repeating Characters (Sliding Window)
-
Minimum Window Substring (Sliding Window + Hashmap)
-
Longest Palindromic Substring (DP/Expand Around Center)
-
Regular Expression Matching (DP)
-
Wildcard Matching (DP)
-
First Missing Positive (Array Manipulation)
-
Sliding Window Maximum (Monotonic Queue)
-
Find All Anagrams in a String (Sliding Window + Hash)
动态规划(Dynamic Programming / DP)
-
Edit Distance (Word Transformation)
-
Longest Increasing Subsequence (LIS) (Binary Search Optimized)
-
Maximum Subarray (Kadane’s Algorithm)
-
Coin Change (Unbounded Knapsack)
-
Word Break (DP + Trie)
-
Decode Ways (String to Number DP)
-
Best Time to Buy and Sell Stock IV (DP with Transactions)
-
Burst Balloons (Matrix Chain Multiplication DP)
-
Russian Doll Envelopes (LIS Variant)
-
Palindrome Partitioning II (DP Optimization)
图(Graph & BFS/DFS)
-
Number of Islands (DFS/BFS)
-
Course Schedule (Topological Sort)
-
Alien Dictionary (Topological Sort)
-
Word Ladder (BFS + Shortest Path)
-
Pacific Atlantic Water Flow (Multi-Source BFS)
-
Longest Consecutive Sequence (Union Find/HashSet)
-
Graph Valid Tree (Union Find/DFS Cycle Detection)
-
Redundant Connection (Union Find)
-
Critical Connections in a Network (Tarjan’s Algorithm)
-
Cheapest Flights Within K Stops (Dijkstra’s Variant)
Binary Trees & Tries
-
Serialize and Deserialize Binary Tree (BFS/DFS)
-
Binary Tree Maximum Path Sum (Post-Order DFS)
-
Construct Binary Tree from Preorder and Inorder Traversal (Recursion)
-
Word Search II (Trie + Backtracking)
-
Kth Smallest Element in a BST (In-Order Traversal)
-
Lowest Common Ancestor of a Binary Tree (Recursive DFS)
-
Vertical Order Traversal of a Binary Tree (BFS + Sorting)
-
Binary Tree Cameras (Greedy DFS)
-
Sum of Distances in Tree (Post-Order + Pre-Order DFS)
-
Path Sum III (Prefix Sum + DFS)
堆/优先队列(Heap & Priority Queue)
-
Merge k Sorted Lists (Min-Heap)
-
Find Median from Data Stream (Two Heaps)
-
Top K Frequent Elements (Bucket Sort/Min-Heap)
-
Task Scheduler (Greedy + Max-Heap)
-
Kth Largest Element in an Array (Quickselect/Heap)
链表(Linked Lists)
-
Merge Two Sorted Lists (Two Pointers)
-
Reverse Nodes in k-Group (Iterative/Recursive)
-
LRU Cache (Hash + Doubly Linked List)
-
LFU Cache (Hash + Heaps/Linked Lists)
-
Copy List with Random Pointer (Hash/Interleaving)
其他(Miscellaneous Hard Problems)
-
N-Queens (Backtracking)
-
Sudoku Solver (Backtracking)
-
Minimum Number of Refueling Stops (Greedy + Heap)
-
Race Car (BFS/DP)
-
Constrained Subsequence Sum (Monotonic Queue)