题库chevron_right分类chevron_right设计
architecture

设计

94 道题目
简单: 10中等: 60困难: 24

设计 是技术面试里最常出现的能力维度之一。建议先掌握基础题型的边界处理,再逐步过渡到模式识别和复杂度 trade-off。

面试场景

高频考察问题建模、边界条件与口头表达的清晰度。

常见误区

只背模板不解释为什么,容易在追问里失分。

练习策略

每轮练 3-5 题,固定复盘复杂度和可替代解法。

推荐练习顺序

#题目难度
146

LRU 缓存

Implement an efficient LRU Cache using hash table and doubly-linked list to achieve O(1) operations for get and put.

中等
155

最小栈

Design a stack with O(1) operations to push, pop, retrieve the top element, and get the minimum element in constant time…

中等
173

二叉搜索树迭代器

Implement an iterator for in-order traversal of a binary search tree (BST), maintaining traversal state with stack-based…

中等
208

实现 Trie (前缀树)

This problem requires designing a Trie (Prefix Tree) to efficiently store and query strings using hash table concepts fo…

中等
211

添加与搜索单词 - 数据结构设计

Build a WordDictionary supporting dynamic word addition and search with wildcard matching efficiently using Trie and DFS…

中等
225

用队列实现栈

This problem tests your ability to simulate a LIFO stack using two queues while preserving all standard stack operations…

简单
232

用栈实现队列

Implement a queue using two stacks, focusing on stack-based state management to achieve FIFO behavior in a queue.

简单
284

窥视迭代器

Design an iterator with peek functionality, adding to the standard next and hasNext operations for efficient element acc…

中等
295

数据流的中位数

Implement a MedianFinder class that supports adding numbers and finding the median from a data stream.

困难
297

二叉树的序列化与反序列化

This problem asks to serialize and deserialize a binary tree, requiring an efficient approach to handle traversal and st…

困难
303

区域和检索 - 数组不可变

The Range Sum Query - Immutable problem involves implementing a data structure to handle range sum queries efficiently.

简单
304

二维区域和检索 - 矩阵不可变

Design a 2D matrix class that efficiently handles sum queries with O(1) time complexity using a prefix sum approach.

中等
307

区域和检索 - 数组可修改

Implement a mutable range sum query using efficient design patterns to handle multiple updates and range sum queries.

中等
341

扁平化嵌套列表迭代器

Implement an iterator to flatten a nested list of integers, accounting for potential nesting levels.

中等
352

将数据流变为多个不相交区间

The problem involves designing a class to summarize a data stream of non-negative integers as disjoint intervals using b…

困难
355

设计推特

Design Twitter requires implementing post, follow, unfollow, and news feed retrieval using linked-list pointer manipulat…

中等
380

O(1) 时间插入、删除和获取随机元素

Implement a data structure supporting insert, delete, and getRandom in average O(1) using array plus hash mapping.

中等
381

O(1) 时间插入、删除和获取随机元素 - 允许重复

This problem challenges you to design a data structure that supports insertion, removal, and random access with O(1) tim…

困难
384

打乱数组

Shuffle an Array requires designing a class to randomly permute an integer array while ensuring all permutations are equ…

中等
432

全 O(1) 的数据结构

Implement a data structure that tracks string counts and retrieves max or min keys efficiently in constant time.

困难
449

序列化和反序列化二叉搜索树

Design an algorithm to serialize and deserialize a binary search tree with efficient traversal and state tracking.

中等
460

LFU 缓存

Implement an LFU Cache using linked-list pointer manipulation with constant-time get and put operations for interview sc…

困难
535

TinyURL 的加密与解密

Design a class that encodes and decodes URLs using a URL shortening approach based on hash tables and strings.

中等
622

设计循环队列

Design a circular queue that allows efficient FIFO operations using linked-list pointer manipulation to optimize space u…

中等
641

设计循环双端队列

Design and implement a circular deque using linked-list pointer manipulation, ensuring efficient insertion and deletion …

中等
676

实现一个魔法字典

Design a Magic Dictionary to allow searching with one-character modifications, using Hash Table and String techniques.

中等
677

键值映射

Design and implement a data structure that supports efficient insertion and sum queries based on string prefixes.

中等
703

数据流中的第 K 大元素

Find the kth largest element in a dynamic stream using binary-tree traversal and efficient state tracking with a min-hea…

简单
705

设计哈希集合

Implement a custom HashSet without built-in libraries using array scanning and hash lookup for efficient membership chec…

简单
706

设计哈希映射

Implement a custom HashMap from scratch using array scanning and hash lookup without built-in libraries for efficient ke…

简单
707

设计链表

Implement a custom linked list supporting head, tail, index insertions, retrieval, and deletions efficiently with pointe…

中等
715

Range 模块

Design a RangeModule to track and query half-open intervals using segment trees or ordered sets.

困难
729

我的日程安排表 I

Implement a calendar supporting non-overlapping event bookings using binary search for efficient insertion and conflict …

中等
731

我的日程安排表 II

Implement a calendar that allows double bookings but prevents triple bookings, managing overlapping intervals efficientl…

中等
732

我的日程安排表 III

Implement My Calendar III to track maximum overlapping events efficiently using binary search and segment tree technique…

困难
745

前缀和后缀搜索

Design a dictionary to search words by both prefix and suffix using a Trie structure and hash lookups.

困难
855

考场就座

Simulate an exam room where each student chooses a seat maximizing distance to others, using design plus heap structures…

中等
895

最大频率栈

Design a stack-like data structure to manage elements and handle frequent stack operations, including popping the most f…

困难
900

RLE 迭代器

Design an efficient iterator for a run-length encoded array, handling large counts and sequential access correctly every…

中等
901

股票价格跨度

Design an efficient algorithm using stacks to calculate the stock span for daily price quotes.

中等
911

在线选举

Solve the Online Election problem by implementing a class that tracks votes and queries the leading candidate at any giv…

中等
919

完全二叉树插入器

Implement a data structure to insert nodes into a complete binary tree while preserving its completeness efficiently.

中等
933

最近的请求次数

The "Number of Recent Calls" problem involves designing a class to efficiently track recent requests within a time windo…

简单
981

基于时间的键值存储

Implement a time-based key-value store that retrieves the latest value at a given timestamp using efficient binary searc…

中等
1032

字符流

Implement a StreamChecker that detects if any suffix of a character stream matches a given list of words using efficient…

困难
1146

快照数组

Implement a SnapshotArray that efficiently tracks element changes and retrieves past states using array scanning and has…

中等
1157

子数组中占绝大多数的元素

Efficiently find the majority element in any subarray using a data structure optimized for multiple range queries.

困难
1172

餐盘栈

Design a system that manages dinner plate stacks using stack-based state management, handling dynamic plate placement an…

困难
1206

设计跳表

Implement a Skiplist efficiently using linked-list pointer manipulation to support search, add, and erase operations in …

困难
1261

在受污染的二叉树中查找元素

Recover values in a contaminated binary tree and efficiently check for existence using traversal and state tracking tech…

中等
1286

字母组合迭代器

Implement an iterator that generates all combinations of a given length using efficient backtracking with pruning.

中等
1348

推文计数

Design an efficient solution to track and retrieve tweet counts over different frequencies using binary search and hash …

中等
1352

最后 K 个数的乘积

Design a data structure to efficiently return the product of the last k numbers in a dynamic integer stream using prefix…

中等
1357

每隔 n 个顾客打折

Compute customer bills with periodic discounts efficiently using array scanning and hash mapping for fast product price …

中等
1381

设计一个支持增量操作的栈

Implement a stack that supports push, pop, and targeted increment operations efficiently using array-based state managem…

中等
1396

设计地铁系统

Design an underground system to calculate travel times between stations using hash tables for efficient lookups and aver…

中等
1472

设计浏览器历史记录

Implement a browser history tracker with back, forward, and visit operations using linked-list pointer manipulation effi…

中等
1476

子矩形查询

Implement the SubrectangleQueries class to handle dynamic updates and value queries on a 2D rectangle.

中等
1483

树节点的第 K 个祖先

Find the kth ancestor of any node in a tree using efficient binary-tree traversal and dynamic state tracking methods.

困难
1600

王位继承顺序

Throne Inheritance requires modeling a dynamic family tree with births and deaths to determine the kingdom's inheritance…

中等
1603

设计停车系统

Implement a class to manage a parking lot with fixed slots for big, medium, and small cars, tracking occupancy efficient…

简单
1622

奇妙序列

Implement a Fancy sequence supporting append, addAll, and multAll operations efficiently using cumulative math design te…

困难
1656

设计有序流

Design an Ordered Stream that returns values in increasing order based on unique integer IDs with efficient insertion an…

简单
1670

设计前中后队列

Implement a queue that efficiently handles push and pop operations at the front, middle, and back using pointer manipula…

中等
1797

设计一个验证系统

Implement an AuthenticationManager using linked-list pointer manipulation and a hash map to track token expirations effi…

中等
1825

求出 MK 平均值

Find the MKAverage of a stream of integers using a queue-driven approach with efficient state management.

困难
1845

座位预约管理系统

Manage seat reservations efficiently using a design combining priority queue to always return the lowest available seat …

中等
1865

找出和为指定值的下标对

Efficiently track and count pairs across two arrays using array scanning plus hash lookup to support dynamic updates.

中等
1912

设计电影租借系统

Implement a movie rental system with efficient search, rent, drop, and report operations using arrays and hash lookups.

困难
1993

树上的操作

Design a tree data structure that allows locking, unlocking, and upgrading nodes with user-specific actions.

中等
2013

检测正方形

Detect Squares requires tracking points on a 2D plane to quickly count all possible axis-aligned squares using efficient…

中等
2034

股票价格波动

Design an efficient algorithm for managing stock price fluctuations with incorrect and unordered data in a data stream.

中等
2043

简易银行系统

Design a simple bank system that processes transactions like withdrawals, deposits, and transfers while managing account…

中等
2069

模拟行走机器人 II

The Walking Robot Simulation II problem challenges you to simulate robot movements and track its position and direction …

中等
2080

区间内查询数字的频率

Design a data structure to handle efficient frequency queries for subarrays, focusing on hash-based lookups and efficien…

中等
2102

序列顺序查询

Track rankings of locations with names and scores, adding new locations and retrieving top-ranked ones efficiently.

困难
2166

设计位集

Master the Design Bitset problem by efficiently managing bit flips, counts, and indexed updates with array and hash look…

中等
2227

加密解密字符串

The 'Encrypt and Decrypt Strings' problem involves creating a data structure that can encrypt and decrypt strings using …

困难
2241

设计一个 ATM 机器

Design an ATM machine that stores and withdraws money with given denominations and prioritizes larger values during with…

中等
2276

统计区间中的整数数目

Design and implement a data structure to efficiently add intervals and count the total number of integers covered by the…

困难
2286

以组为单位订音乐会的门票

Design a ticketing system to allocate concert seats in specific groupings while efficiently handling seat reservations.

困难
2296

设计一个文本编辑器

Design a text editor that supports text manipulation and cursor navigation operations efficiently with linked-list-based…

困难
2336

无限集中的最小数字

Design a data structure to handle the smallest missing element in an infinite set, with the ability to add and remove el…

中等
2349

设计数字容器系统

Learn to implement a Number Container System using hash tables and design techniques to efficiently track numbers and in…

中等
2353

设计食物评分系统

Design a food rating system that tracks and updates ratings of foods, finding the highest rated items by cuisine.

中等
2424

最长上传前缀

Calculate the longest continuous uploaded prefix in a video stream efficiently using a mix of binary search and data str…

中等
2502

设计内存分配器

Design a memory allocator that simulates allocation and deallocation of memory blocks.

中等
2526

找到数据流中的连续整数

Design a data stream checker to identify consecutive integers from a stream, focusing on handling state transitions effi…

中等
2642

设计可以求最短路径的图类

Implement a dynamic weighted directed graph with efficient shortest path queries and edge additions in real time.

困难
2671

频率跟踪器

Design a data structure to track values and answer frequency-related queries efficiently using hash tables.

中等
3242

设计相邻元素求和服务

Design a service that computes sums for adjacent and diagonal elements in a 2D grid.

简单
3408

设计任务管理器

Design a Task Manager that can efficiently handle task management operations such as adding, editing, executing, and rem…

中等
3484

设计电子表格

Design a spreadsheet that supports setting, retrieving, and resetting values, with the ability to handle formulas refere…

中等
3508

设计路由器

Efficiently design a Router class to manage network packets with memory limits using array scanning and hash lookups.

中等

关联高频模式

LeetCode 设计题型题解:94题训练路线