面试场景
高频考察问题建模、边界条件与口头表达的清晰度。
常见误区
只背模板不解释为什么,容易在追问里失分。
练习策略
每轮练 3-5 题,固定复盘复杂度和可替代解法。
推荐练习顺序
题库
设计 题库
先展示一段最适合快速浏览的题目列表,继续滚动时再慢慢续载,避免专题页被长列表一下子拉穿。
慢加载专题题库
适合这类题很多的专题,先扫结构,再逐步深入。
当前展示 24 / 94 道题目
每次续载 24 题LRU 缓存
Implement an efficient LRU Cache using hash table and doubly-linked list to achieve O(1) operations for get and put.
最小栈
Design a stack with O(1) operations to push, pop, retrieve the top element, and get the minimum element in constant time…
二叉搜索树迭代器
Implement an iterator for in-order traversal of a binary search tree (BST), maintaining traversal state with stack-based…
实现 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…
用队列实现栈
This problem tests your ability to simulate a LIFO stack using two queues while preserving all standard stack operations…
用栈实现队列
Implement a queue using two stacks, focusing on stack-based state management to achieve FIFO behavior in a queue.
窥视迭代器
Design an iterator with peek functionality, adding to the standard next and hasNext operations for efficient element acc…
数据流的中位数
Implement a MedianFinder class that supports adding numbers and finding the median from a data stream.
二叉树的序列化与反序列化
This problem asks to serialize and deserialize a binary tree, requiring an efficient approach to handle traversal and st…
区域和检索 - 数组不可变
The Range Sum Query - Immutable problem involves implementing a data structure to handle range sum queries efficiently.
二维区域和检索 - 矩阵不可变
Design a 2D matrix class that efficiently handles sum queries with O(1) time complexity using a prefix sum approach.
区域和检索 - 数组可修改
Implement a mutable range sum query using efficient design patterns to handle multiple updates and range sum queries.
扁平化嵌套列表迭代器
Implement an iterator to flatten a nested list of integers, accounting for potential nesting levels.
将数据流变为多个不相交区间
The problem involves designing a class to summarize a data stream of non-negative integers as disjoint intervals using b…
设计推特
Design Twitter requires implementing post, follow, unfollow, and news feed retrieval using linked-list pointer manipulat…
O(1) 时间插入、删除和获取随机元素
Implement a data structure supporting insert, delete, and getRandom in average O(1) using array plus hash mapping.
O(1) 时间插入、删除和获取随机元素 - 允许重复
This problem challenges you to design a data structure that supports insertion, removal, and random access with O(1) tim…
打乱数组
Shuffle an Array requires designing a class to randomly permute an integer array while ensuring all permutations are equ…
全 O(1) 的数据结构
Implement a data structure that tracks string counts and retrieves max or min keys efficiently in constant time.
序列化和反序列化二叉搜索树
Design an algorithm to serialize and deserialize a binary search tree with efficient traversal and state tracking.
LFU 缓存
Implement an LFU Cache using linked-list pointer manipulation with constant-time get and put operations for interview sc…
TinyURL 的加密与解密
Design a class that encodes and decodes URLs using a URL shortening approach based on hash tables and strings.
设计循环队列
Design a circular queue that allows efficient FIFO operations using linked-list pointer manipulation to optimize space u…
swap_vert在题库框内继续向下滚动,也会自动续载