面试场景
高频考察问题建模、边界条件与口头表达的清晰度。
常见误区
只背模板不解释为什么,容易在追问里失分。
练习策略
每轮练 3-5 题,固定复盘复杂度和可替代解法。
推荐练习顺序
寻找两个正序数组的中位数
Find the median of two sorted arrays using binary search for efficient O(log(min(m, n))) time complexity.
合并 K 个升序链表
Merge k Sorted Lists requires efficiently combining multiple sorted linked lists into one using pointers and priority qu…
最大子数组和
Maximum Subarray is a classic state transition dynamic programming problem about deciding whether to extend or restart a…
从前序与中序遍历序列构造二叉树
Construct a binary tree using preorder and inorder traversal arrays, leveraging array scanning and hash table lookups.
从中序与后序遍历序列构造二叉树
Reconstruct a binary tree from given inorder and postorder arrays using array scanning and hash lookup to optimize recur…
将有序数组转换为二叉搜索树
Pick the middle element as root at each step so the sorted array becomes a height-balanced BST with valid ordering.
有序链表转换二叉搜索树
Convert a sorted singly linked list into a height-balanced BST using pointer manipulation and divide-and-conquer recursi…
排序链表
Sort List requires sorting a singly linked list efficiently using pointer manipulation and merge sort for optimal perfor…
多数元素
Find the majority element in an array, where the element appears more than n/2 times, using efficient algorithms.
颠倒二进制位
Reverse a 32-bit unsigned integer by manipulating bits efficiently using a divide and conquer approach with careful bit …
位1的个数
Number of 1 Bits is a classic bit manipulation problem where clearing the lowest set bit gives the cleanest count.
数组中的第K个最大元素
Find the kth largest element in an unsorted array using optimal approaches like Quickselect or heaps.
天际线问题
The Skyline Problem requires calculating a city's silhouette using array manipulation and divide-and-conquer techniques …
搜索二维矩阵 II
Efficiently search for a target in a 2D matrix using binary search and matrix properties.
计算右侧小于当前元素的个数
Solve the Count of Smaller Numbers After Self problem using binary search and optimized algorithms.
摆动排序 II
Rearrange an array in a way that every odd-indexed element is greater than its adjacent even-indexed elements.
区间和的个数
Count the number of subarray sums within a given inclusive range using optimized divide-and-conquer techniques efficient…
前 K 个高频元素
Find the k most frequent elements from an array using efficient algorithms like hashing and sorting.
超级次方
Compute large exponentiations efficiently using modular arithmetic and divide-and-conquer techniques for this Super Pow …
至少有 K 个重复字符的最长子串
Find the length of the longest substring where every character appears at least k times using sliding window and divide-…
建立四叉树
Construct a Quad-Tree from a binary matrix by recursively subdividing regions and tracking uniform states efficiently.
翻转对
Count the number of reverse pairs in a given integer array using efficient algorithms like binary search and merge sort.
四叉树交集
Compute the logical OR of two binary matrices represented as Quad-Trees using recursive tree traversal and state propaga…
最大二叉树
Construct a maximum binary tree by recursively selecting the largest element and dividing the array into left and right …
根据前序和后序遍历构造二叉树
Reconstruct a binary tree from preorder and postorder traversals using array scanning and hash lookup.
排序数组
Sort an array using an optimal algorithm, focusing on time and space complexity considerations.
环形子数组的最大和
Find the maximum sum of a circular subarray using state transition dynamic programming, optimizing for wraparound cases …
漂亮数组
Beautiful Array builds a valid permutation by recursively separating odd and even positions so no middle-average triple …
最接近原点的 K 个点
Find the k closest points to the origin in a 2D plane using array operations and Euclidean distance calculations efficie…
将二叉搜索树变平衡
This problem requires balancing a binary search tree using in-order traversal and state tracking techniques.
将子数组重新排序得到同一个二叉搜索树的方案数
Determine the number of ways to reorder an array to get the same binary search tree (BST) from its insertion order.
通过指令创建有序数组
The problem asks to compute the cost of inserting elements into a sorted array using a series of instructions.
找出第 K 大的异或坐标值
Compute the kth largest XOR coordinate in a 2D matrix using prefix sums, bit manipulation, and optimized selection techn…
最长的美好子字符串
Find the longest nice substring in a given string using the sliding window technique with running state updates.
从子集的和还原数组
Reconstruct an array from given subset sums using divide and conquer approach and leveraging array properties.
找出数组中的第 K 大整数
This problem asks to find the kth largest integer in an array of string numbers, highlighting sorting and string-based c…
统计数组中好三元组数目
Count Good Triplets in an Array requires tracking index orders across two permutations efficiently using binary search.
裁剪数字后查询第 K 小的数字
Solve the Query Kth Smallest Trimmed Number problem by efficiently trimming and sorting strings in an array to answer qu…
最长递增子序列 II
Determine the longest increasing subsequence in an array where consecutive elements differ by at most k using dynamic pr…
满足不等式的数对数目
Count pairs in two arrays satisfying a given inequality condition using binary search over the valid answer space.
不包含相邻元素的子序列的最大和
Compute the maximum sum of a subsequence where no two adjacent elements are selected after each array update efficiently…
填充特殊网格
Fill a Special Grid uses recursive divide-and-conquer to populate a 2^n x 2^n matrix with sequential integers uniquely i…