Design Problems

Master design problems with AI-powered solutions. Get instant coding assistance during your technical interviews for all 83 problems in this category.

Total Problems: 83
Easy: 9
Medium: 51
Hard: 23
Showing 50 of 83 problems

Problems

Scroll within this area to browse all problems

#
Title
Difficulty
146

LRU Cache

Medium
460

LFU Cache

Hard
295

Find Median from Data Stream

Hard
208

Implement Trie (Prefix Tree)

Medium
155

Min Stack

Medium
297

Serialize and Deserialize Binary Tree

Hard
355

Design Twitter

Medium
817

Design HashMap

Easy
380

Insert Delete GetRandom O(1)

Medium
1708

Design Parking System

Easy
838

Design Linked List

Medium
225

Implement Stack using Queues

Easy
341

Flatten Nested List Iterator

Medium
232

Implement Queue using Stacks

Easy
860

Design Circular Queue

Medium
384

Shuffle an Array

Medium
937

Online Stock Span

Medium
2778

Frequency Tracker

Medium
211

Design Add and Search Words Data Structure

Medium
715

Range Module

Hard
381

Insert Delete GetRandom O(1) - Duplicates allowed

Hard
885

Exam Room

Medium
173

Binary Search Tree Iterator

Medium
1023

Time Based Key-Value Store

Medium
816

Design HashSet

Easy
1459

Apply Discount Every n Orders

Medium
789

Kth Largest Element in a Stream

Easy
2161

Stock Price Fluctuation

Medium
859

Design Circular Deque

Medium
1582

Design Browser History

Medium
969

Number of Recent Calls

Easy
931

Maximum Frequency Stack

Hard
2357

Count Integers in Intervals

Hard
2352

Design an ATM Machine

Medium
746

Prefix and Suffix Search

Hard
2169

Simple Bank System

Medium
352

Data Stream as Disjoint Intervals

Hard
535

Encode and Decode TinyURL

Medium
3797

Design Spreadsheet

Medium
449

Serialize and Deserialize BST

Medium
303

Range Sum Query - Immutable

Easy
1995

Finding Pairs With a Certain Sum

Medium
2429

Design a Food Rating System

Medium
2207

Sequentially Ordinal Rank Tracker

Hard
676

Implement Magic Dictionary

Medium
307

Range Sum Query - Mutable

Medium
732

My Calendar III

Hard
936

RLE Iterator

Medium
2389

Design a Text Editor

Hard
1249

Snapshot Array

Medium
Loading more problems...

Design LeetCode Problems List

  • 146. LRU Cache - Medium - DesignDesign a data structure that follows the constraints of a Least Recently Used (LRU) cache. Implement the LRUCache class: LRUCache(int capacity) Initia... Topics: Hash Table, Linked List, Design, Doubly-Linked List
  • 460. LFU Cache - Hard - DesignDesign and implement a data structure for a Least Frequently Used (LFU) cache. Implement the LFUCache class: LFUCache(int capacity) Initializes the ob... Topics: Hash Table, Linked List, Design, Doubly-Linked List
  • 295. Find Median from Data Stream - Hard - DesignThe median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value, and the median is the mean of th... Topics: Two Pointers, Design, Sorting, Heap (Priority Queue), Data Stream
  • 208. Implement Trie (Prefix Tree) - Medium - DesignA trie (pronounced as "try") or prefix tree is a tree data structure used to efficiently store and retrieve keys in a dataset of strings. There are va... Topics: Hash Table, String, Design, Trie
  • 155. Min Stack - Medium - DesignDesign a stack that supports push, pop, top, and retrieving the minimum element in constant time. Implement the MinStack class: MinStack() initializes... Topics: Stack, Design
  • 297. Serialize and Deserialize Binary Tree - Hard - DesignSerialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or ... Topics: String, Tree, Depth-First Search, Breadth-First Search, Design, Binary Tree
  • 355. Design Twitter - Medium - DesignDesign a simplified version of Twitter where users can post tweets, follow/unfollow another user, and is able to see the 10 most recent tweets in the ... Topics: Hash Table, Linked List, Design, Heap (Priority Queue)
  • 817. Design HashMap - Easy - DesignDesign a HashMap without using any built-in hash table libraries. Implement the MyHashMap class: MyHashMap() initializes the object with an empty map.... Topics: Array, Hash Table, Linked List, Design, Hash Function
  • 380. Insert Delete GetRandom O(1) - Medium - DesignImplement the RandomizedSet class: RandomizedSet() Initializes the RandomizedSet object. bool insert(int val) Inserts an item val into the set if not ... Topics: Array, Hash Table, Math, Design, Randomized
  • 1708. Design Parking System - Easy - DesignDesign a parking system for a parking lot. The parking lot has three kinds of parking spaces: big, medium, and small, with a fixed number of slots for... Topics: Design, Simulation, Counting
  • 838. Design Linked List - Medium - DesignDesign your implementation of the linked list. You can choose to use a singly or doubly linked list. A node in a singly linked list should have two at... Topics: Linked List, Design
  • 225. Implement Stack using Queues - Easy - DesignImplement a last-in-first-out (LIFO) stack using only two queues. The implemented stack should support all the functions of a normal stack (push, top,... Topics: Stack, Design, Queue
  • 341. Flatten Nested List Iterator - Medium - DesignYou are given a nested list of integers nestedList. Each element is either an integer or a list whose elements may also be integers or other lists. Im... Topics: Stack, Tree, Depth-First Search, Design, Queue, Iterator
  • 232. Implement Queue using Stacks - Easy - DesignImplement a first in first out (FIFO) queue using only two stacks. The implemented queue should support all the functions of a normal queue (push, pee... Topics: Stack, Design, Queue
  • 860. Design Circular Queue - Medium - DesignDesign your implementation of the circular queue. The circular queue is a linear data structure in which the operations are performed based on FIFO (F... Topics: Array, Linked List, Design, Queue
  • 384. Shuffle an Array - Medium - DesignGiven an integer array nums, design an algorithm to randomly shuffle the array. All permutations of the array should be equally likely as a result of ... Topics: Array, Math, Design, Randomized
  • 937. Online Stock Span - Medium - DesignDesign an algorithm that collects daily price quotes for some stock and returns the span of that stock's price for the current day. The span of the st... Topics: Stack, Design, Monotonic Stack, Data Stream
  • 2778. Frequency Tracker - Medium - DesignDesign a data structure that keeps track of the values in it and answers some queries regarding their frequencies. Implement the FrequencyTracker clas... Topics: Hash Table, Design
  • 211. Design Add and Search Words Data Structure - Medium - DesignDesign a data structure that supports adding new words and finding if a string matches any previously added string. Implement the WordDictionary class... Topics: String, Depth-First Search, Design, Trie
  • 715. Range Module - Hard - DesignA Range Module is a module that tracks ranges of numbers. Design a data structure to track the ranges represented as half-open intervals and query abo... Topics: Design, Segment Tree, Ordered Set
  • 381. Insert Delete GetRandom O(1) - Duplicates allowed - Hard - DesignRandomizedCollection is a data structure that contains a collection of numbers, possibly duplicates (i.e., a multiset). It should support inserting an... Topics: Array, Hash Table, Math, Design, Randomized
  • 885. Exam Room - Medium - DesignThere is an exam room with n seats in a single row labeled from 0 to n - 1. When a student enters the room, they must sit in the seat that maximizes t... Topics: Design, Heap (Priority Queue), Ordered Set
  • 173. Binary Search Tree Iterator - Medium - DesignImplement the BSTIterator class that represents an iterator over the in-order traversal of a binary search tree (BST): BSTIterator(TreeNode root) Init... Topics: Stack, Tree, Design, Binary Search Tree, Binary Tree, Iterator
  • 1023. Time Based Key-Value Store - Medium - DesignDesign a time-based key-value data structure that can store multiple values for the same key at different time stamps and retrieve the key's value at ... Topics: Hash Table, String, Binary Search, Design
  • 816. Design HashSet - Easy - DesignDesign a HashSet without using any built-in hash table libraries. Implement MyHashSet class: void add(key) Inserts the value key into the HashSet. boo... Topics: Array, Hash Table, Linked List, Design, Hash Function
  • 1459. Apply Discount Every n Orders - Medium - DesignThere is a supermarket that is frequented by many customers. The products sold at the supermarket are represented as two parallel integer arrays produ... Topics: Array, Hash Table, Design
  • 789. Kth Largest Element in a Stream - Easy - DesignYou are part of a university admissions office and need to keep track of the kth highest test score from applicants in real-time. This helps to determ... Topics: Tree, Design, Binary Search Tree, Heap (Priority Queue), Binary Tree, Data Stream
  • 2161. Stock Price Fluctuation - Medium - DesignYou are given a stream of records about a particular stock. Each record contains a timestamp and the corresponding price of the stock at that timestam... Topics: Hash Table, Design, Heap (Priority Queue), Data Stream, Ordered Set
  • 859. Design Circular Deque - Medium - DesignDesign your implementation of the circular double-ended queue (deque). Implement the MyCircularDeque class: MyCircularDeque(int k) Initializes the deq... Topics: Array, Linked List, Design, Queue
  • 1582. Design Browser History - Medium - DesignYou have a browser of one tab where you start on the homepage and you can visit another url, get back in the history number of steps or move forward i... Topics: Array, Linked List, Stack, Design, Doubly-Linked List, Data Stream
  • 969. Number of Recent Calls - Easy - DesignYou have a RecentCounter class which counts the number of recent requests within a certain time frame. Implement the RecentCounter class: RecentCounte... Topics: Design, Queue, Data Stream
  • 931. Maximum Frequency Stack - Hard - DesignDesign a stack-like data structure to push elements to the stack and pop the most frequent element from the stack. Implement the FreqStack class: Freq... Topics: Hash Table, Stack, Design, Ordered Set
  • 2357. Count Integers in Intervals - Hard - DesignGiven an empty set of intervals, implement a data structure that can: Add an interval to the set of intervals. Count the number of integers that are p... Topics: Design, Segment Tree, Ordered Set
  • 2352. Design an ATM Machine - Medium - DesignThere is an ATM machine that stores banknotes of 5 denominations: 20, 50, 100, 200, and 500 dollars. Initially the ATM is empty. The user can use the ... Topics: Array, Greedy, Design
  • 746. Prefix and Suffix Search - Hard - DesignDesign a special dictionary that searches the words in it by a prefix and a suffix. Implement the WordFilter class: WordFilter(string[] words) Initial... Topics: Array, Hash Table, String, Design, Trie
  • 2169. Simple Bank System - Medium - DesignYou have been tasked with writing a program for a popular bank that will automate all its incoming transactions (transfer, deposit, and withdraw). The... Topics: Array, Hash Table, Design, Simulation
  • 352. Data Stream as Disjoint Intervals - Hard - DesignGiven a data stream input of non-negative integers a1, a2, ..., an, summarize the numbers seen so far as a list of disjoint intervals. Implement the S... Topics: Binary Search, Design, Ordered Set
  • 535. Encode and Decode TinyURL - Medium - DesignNote: This is a companion problem to the System Design problem: Design TinyURL. TinyURL is a URL shortening service where you enter a URL such as http... Topics: Hash Table, String, Design, Hash Function
  • 3797. Design Spreadsheet - Medium - DesignA spreadsheet is a grid with 26 columns (labeled from 'A' to 'Z') and a given number of rows. Each cell in the spreadsheet can hold an integer value b... Topics: Array, Hash Table, String, Design, Matrix
  • 449. Serialize and Deserialize BST - Medium - DesignSerialization is converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted acr... Topics: String, Tree, Depth-First Search, Breadth-First Search, Design, Binary Search Tree, Binary Tree
  • 303. Range Sum Query - Immutable - Easy - DesignGiven an integer array nums, handle multiple queries of the following type: Calculate the sum of the elements of nums between indices left and right i... Topics: Array, Design, Prefix Sum
  • 1995. Finding Pairs With a Certain Sum - Medium - DesignYou are given two integer arrays nums1 and nums2. You are tasked to implement a data structure that supports queries of two types: Add a positive inte... Topics: Array, Hash Table, Design
  • 2429. Design a Food Rating System - Medium - DesignDesign a food rating system that can do the following: Modify the rating of a food item listed in the system. Return the highest-rated food item for a... Topics: Array, Hash Table, String, Design, Heap (Priority Queue), Ordered Set
  • 2207. Sequentially Ordinal Rank Tracker - Hard - DesignA scenic location is represented by its name and attractiveness score, where name is a unique string among all locations and score is an integer. Loca... Topics: Design, Heap (Priority Queue), Data Stream, Ordered Set
  • 676. Implement Magic Dictionary - Medium - DesignDesign a data structure that is initialized with a list of different words. Provided a string, you should determine if you can change exactly one char... Topics: Hash Table, String, Depth-First Search, Design, Trie
  • 307. Range Sum Query - Mutable - Medium - DesignGiven an integer array nums, handle multiple queries of the following types: Update the value of an element in nums. Calculate the sum of the elements... Topics: Array, Divide and Conquer, Design, Binary Indexed Tree, Segment Tree
  • 732. My Calendar III - Hard - DesignA k-booking happens when k events have some non-empty intersection (i.e., there is some time that is common to all k events.) You are given some event... Topics: Binary Search, Design, Segment Tree, Prefix Sum, Ordered Set
  • 936. RLE Iterator - Medium - DesignWe can use run-length encoding (i.e., RLE) to encode a sequence of integers. In a run-length encoded array of even length encoding (0-indexed), for al... Topics: Array, Design, Counting, Iterator
  • 2389. Design a Text Editor - Hard - DesignDesign a text editor with a cursor that can do the following: Add text to where the cursor is. Delete text from where the cursor is (simulating the ba... Topics: Linked List, String, Stack, Design, Simulation, Doubly-Linked List
  • 1249. Snapshot Array - Medium - DesignImplement a SnapshotArray that supports the following interface: SnapshotArray(int length) initializes an array-like data structure with the given len... Topics: Array, Hash Table, Binary Search, Design
  • 1955. Seat Reservation Manager - Medium - DesignDesign a system that manages the reservation state of n seats that are numbered from 1 to n. Implement the SeatManager class: SeatManager(int n) Initi... Topics: Design, Heap (Priority Queue)
  • 1775. Design an Ordered Stream - Easy - DesignThere is a stream of n (idKey, value) pairs arriving in an arbitrary order, where idKey is an integer between 1 and n and value is a string. No two pa... Topics: Array, Hash Table, Design, Data Stream
  • 1767. Design Front Middle Back Queue - Medium - DesignDesign a queue that supports push and pop operations in the front, middle, and back. Implement the FrontMiddleBack class: FrontMiddleBack() Initialize... Topics: Array, Linked List, Design, Queue, Data Stream
  • 2678. Design Graph With Shortest Path Calculator - Hard - DesignThere is a directed weighted graph that consists of n nodes numbered from 0 to n - 1. The edges of the graph are initially represented by the given ar... Topics: Graph, Design, Heap (Priority Queue), Shortest Path
  • 1728. Fancy Sequence - Hard - DesignWrite an API that generates fancy sequences using the append, addAll, and multAll operations. Implement the Fancy class: Fancy() Initializes the objec... Topics: Math, Design, Segment Tree
  • 1905. Design Authentication Manager - Medium - DesignThere is an authentication system that works with authentication tokens. For each session, the user will receive a new authentication token that will ... Topics: Hash Table, Linked List, Design, Doubly-Linked List
  • 1433. Encrypt and Decrypt Strings - Hard - DesignYou are given a character array keys containing unique characters and a string array values containing strings of length 2. You are also given another... Topics: Array, Hash Table, String, Design, Trie
  • 1497. Design a Stack With Increment Operation - Medium - DesignDesign a stack that supports increment operations on its elements. Implement the CustomStack class: CustomStack(int maxSize) Initializes the object wi... Topics: Array, Stack, Design
  • 2023. Design Movie Rental System - Hard - DesignYou have a movie renting company consisting of n shops. You want to implement a renting system that supports searching for, booking, and returning mov... Topics: Array, Hash Table, Design, Heap (Priority Queue), Ordered Set
  • 304. Range Sum Query 2D - Immutable - Medium - DesignGiven a 2D matrix matrix, handle multiple queries of the following type: Calculate the sum of the elements of matrix inside the rectangle defined by i... Topics: Array, Design, Matrix, Prefix Sum
  • 1953. Finding MK Average - Hard - DesignYou are given two integers, m and k, and a stream of integers. You are tasked to implement a data structure that calculates the MKAverage for the stre... Topics: Design, Queue, Heap (Priority Queue), Data Stream, Ordered Set
  • 1097. Stream of Characters - Hard - DesignDesign an algorithm that accepts a stream of characters and checks if a suffix of these characters is a string of a given array of strings words. For ... Topics: Array, String, Design, Trie, Data Stream
  • 955. Complete Binary Tree Inserter - Medium - DesignA complete binary tree is a binary tree in which every level, except possibly the last, is completely filled, and all nodes are as far left as possibl... Topics: Tree, Breadth-First Search, Design, Binary Tree
  • 1512. Design Underground System - Medium - DesignAn underground railway system is keeping track of customer travel times between different stations. They are using this data to calculate the average ... Topics: Hash Table, String, Design
  • 1270. Dinner Plate Stacks - Hard - DesignYou have an infinite number of stacks arranged in a row and numbered (left to right) from 0, each of the stacks has the same maximum capacity. Impleme... Topics: Hash Table, Stack, Design, Heap (Priority Queue)
  • 432. All O`one Data Structure - Hard - DesignDesign a data structure to store the strings' count with the ability to return the strings with minimum and maximum counts. Implement the AllOne class... Topics: Hash Table, Linked List, Design, Doubly-Linked List
  • 2139. Detect Squares - Medium - DesignYou are given a stream of points on the X-Y plane. Design an algorithm that: Adds new points from the stream into a data structure. Duplicate points a... Topics: Array, Hash Table, Design, Counting
  • 2413. Smallest Number in Infinite Set - Medium - DesignYou have a set which contains all positive integers [1, 2, 3, 4, 5, ...]. Implement the SmallestInfiniteSet class: SmallestInfiniteSet() Initializes t... Topics: Hash Table, Design, Heap (Priority Queue), Ordered Set
  • 1337. Design Skiplist - Hard - DesignDesign a Skiplist without using any built-in libraries. A skiplist is a data structure that takes O(log(n)) time to add, erase and search. Comparing w... Topics: Linked List, Design
  • 2434. Design a Number Container System - Medium - DesignDesign a number container system that can do the following: Insert or Replace a number at the given index in the system. Return the smallest index for... Topics: Hash Table, Design, Heap (Priority Queue), Ordered Set
  • 1722. Throne Inheritance - Medium - DesignA kingdom consists of a king, his children, his grandchildren, and so on. Every once in a while, someone in the family dies or a child is born. The ki... Topics: Hash Table, Tree, Depth-First Search, Design
  • 1296. Kth Ancestor of a Tree Node - Hard - DesignYou are given a tree with n nodes numbered from 0 to n - 1 in the form of a parent array parent where parent[i] is the parent of ith node. The root of... Topics: Binary Search, Dynamic Programming, Tree, Depth-First Search, Breadth-First Search, Design
  • 1470. Tweet Counts Per Frequency - Medium - DesignA social media company is trying to monitor activity on their site by analyzing the number of tweets that occur in select periods of time. These perio... Topics: Hash Table, Binary Search, Design, Sorting, Ordered Set
  • 677. Map Sum Pairs - Medium - DesignDesign a map that allows you to do the following: Maps a string key to a given value. Returns the sum of the values that have a key with a prefix equa... Topics: Hash Table, String, Design, Trie
  • 1294. Range Frequency Queries - Medium - DesignDesign a data structure to find the frequency of a given value in a given subarray. The frequency of a value in a subarray is the number of occurrence... Topics: Array, Hash Table, Binary Search, Design, Segment Tree
  • 2620. Find Consecutive Integers from a Data Stream - Medium - DesignFor a stream of integers, implement a data structure that checks if the last k integers parsed in the stream are equal to value. Implement the DataStr... Topics: Hash Table, Design, Queue, Counting, Data Stream
  • 2380. Booking Concert Tickets in Groups - Hard - DesignA concert hall has n rows numbered from 0 to n - 1, each with m seats, numbered from 0 to m - 1. You need to design a ticketing system that can alloca... Topics: Binary Search, Design, Binary Indexed Tree, Segment Tree
  • 284. Peeking Iterator - Medium - DesignDesign an iterator that supports the peek operation on an existing iterator in addition to the hasNext and the next operations. Implement the PeekingI... Topics: Array, Design, Iterator
  • 2285. Design Bitset - Medium - DesignA Bitset is a data structure that compactly stores bits. Implement the Bitset class: Bitset(int size) Initializes the Bitset with size bits, all of wh... Topics: Array, Hash Table, String, Design
  • 731. My Calendar II - Medium - DesignYou are implementing a program to use as your calendar. We can add a new event if adding the event will not cause a triple booking. A triple booking h... Topics: Array, Binary Search, Design, Segment Tree, Prefix Sum, Ordered Set
  • 2587. Design Memory Allocator - Medium - DesignYou are given an integer n representing the size of a 0-indexed memory array. All memory units are initially free. You have a memory allocator with th... Topics: Array, Hash Table, Design, Simulation
  • 729. My Calendar I - Medium - DesignYou are implementing a program to use as your calendar. We can add a new event if adding the event will not cause a double booking. A double booking h... Topics: Array, Binary Search, Design, Segment Tree, Ordered Set
  • 2104. Operations on Tree - Medium - DesignYou are given a tree with n nodes numbered from 0 to n - 1 in the form of a parent array parent where parent[i] is the parent of the ith node. The roo... Topics: Array, Hash Table, Tree, Depth-First Search, Breadth-First Search, Design

Related LeetCode Topics

Design LeetCode Problems - Interview Coder