面试场景
高频考察问题建模、边界条件与口头表达的清晰度。
常见误区
只背模板不解释为什么,容易在追问里失分。
练习策略
每轮练 3-5 题,固定复盘复杂度和可替代解法。
推荐练习顺序
最长公共前缀
Find the longest common prefix in an array of strings, returning an empty string if none exists.
单词拆分
Determine if a string can be fully segmented into dictionary words using array scanning and hash-based lookups for effic…
单词拆分 II
Given a string and dictionary, return all possible sentences by adding spaces where each word is in the dictionary.
实现 Trie (前缀树)
This problem requires designing a Trie (Prefix Tree) to efficiently store and query strings using hash table concepts fo…
添加与搜索单词 - 数据结构设计
Build a WordDictionary supporting dynamic word addition and search with wildcard matching efficiently using Trie and DFS…
单词搜索 II
Solve the Word Search II problem using backtracking with pruning to find all words on a board of characters.
回文对
Find all pairs of words in a list that form palindromes when concatenated using efficient scanning and hash mapping.
字典序排数
Generate all numbers from 1 to n in lexicographical order using a depth-first search pattern optimized with trie logic f…
数组中两个数的最大异或值
Find the maximum XOR of two numbers in an integer array using efficient bit manipulation techniques.
字典序的第K小数字
Find the k-th lexicographically smallest integer in a range using a Trie-based approach.
连接词
Find concatenated words by using dynamic programming and depth-first search to identify valid words made of other words …
单词替换
Replace words in a sentence using the shortest root from a dictionary, applying efficient array scanning and hash lookup…
实现一个魔法字典
Design a Magic Dictionary to allow searching with one-character modifications, using Hash Table and String techniques.
键值映射
Design and implement a data structure that supports efficient insertion and sum queries based on string prefixes.
前K个高频单词
Solve Top K Frequent Words by counting each word, then ordering ties alphabetically so frequency wins before lexicograph…
词典中最长的单词
Find the longest word in a dictionary that can be built one character at a time from other words in the dictionary.
前缀和后缀搜索
Design a dictionary to search words by both prefix and suffix using a Trie structure and hash lookups.
匹配子序列的单词数
Given a string s and a list of words, count how many words are subsequences of s using efficient array scanning and hash…
单词的压缩编码
Find the minimum length of a reference string encoding an array of words using array scanning and hash lookup efficientl…
驼峰式匹配
Camelcase Matching is a medium difficulty problem where you match queries to a given pattern by inserting lowercase lett…
字符流
Implement a StreamChecker that detects if any suffix of a character stream matches a given list of words using efficient…
猜字谜
Solve the "Number of Valid Words for Each Puzzle" problem with array scanning and hash lookup to efficiently count valid…
删除子文件夹
Remove sub-folders in a filesystem by filtering out folders nested inside other folders.
搜索推荐系统
Design a search suggestion system that provides the top three lexicographically smallest products matching a search word…
不同的循环子字符串
Count the distinct non-empty substrings of a given string that can be formed as the concatenation of a string with itsel…
与数组中元素的最大异或值
Solve the Maximum XOR With an Element From Array problem by efficiently finding the maximum XOR for each query using bit…
统计异或值在范围内的数对有多少
Count all pairs in an array whose XOR falls within a given range using efficient bit manipulation techniques and a trie …
查询最大基因差
Find the maximum genetic difference along paths in a tree using array scanning and hash lookups with XOR calculations.
删除系统中的重复文件夹
Solve Delete Duplicate Folders in System by building a trie, serializing child subtrees, and deleting repeated non-empty…
加密解密字符串
The 'Encrypt and Decrypt Strings' problem involves creating a data structure that can encrypt and decrypt strings using …
含最多 K 个可整除元素的子数组
Count all distinct subarrays with at most k elements divisible by p using array scanning and hash lookup techniques effi…
字符串的前缀分数和
The 'Sum of Prefix Scores of Strings' problem involves calculating prefix scores for strings based on their occurrences …
距离字典两次编辑以内的单词
Identify all words in queries that can match dictionary entries with at most two character changes efficiently using arr…
字符串中的额外字符
The problem asks for the minimum number of extra characters left after optimally breaking a string into substrings found…
找出强数对的最大异或值 I
Find the maximum XOR of any strong pair in an integer array using array scanning and hash-based lookups efficiently.
找出强数对的最大异或值 II
Find the maximum XOR among strong pairs in an array using array scanning and hash-based lookups efficiently.
转换字符串的最小成本 II
Compute the minimum cost to transform source into target using substring replacements with given costs efficiently using…
统计前后缀下标对 I
Count all index pairs where one word is both a prefix and suffix of another, using efficient array and string checks.
最长公共前缀的长度
Determine the length of the longest common prefix between two integer arrays using array scanning and hash lookup effici…
统计前后缀下标对 II
Count the number of index pairs in a string array where one word is both a prefix and suffix of another using array and …
数组中的最短非公共子字符串
Find the shortest substring for each string in an array that does not appear in any other string efficiently using hashi…
最长公共后缀查询
Find the index of the string in wordsContainer with the longest common suffix for each query efficiently using array and…
形成目标字符串需要的最少字符串数 I
Use dynamic programming to split target into the fewest prefixes that match any word prefix, while ruling out dead posit…
删除元素后 K 个字符串的最长公共前缀
Find the longest common prefix length of k strings after removing an element in the array.
分割字符串
Partition a string into unique segments using hash table and string manipulation.