Backend Developer
Stacks, queues and heaps questions
123 questions on Stacks, queues and heaps for backend developers, easiest first.
Easy 39
- Checking balanced bracketseasy
- Order rule of a stackeasy
- Order rule of a queueeasy
- Trace stack push and popeasy
- Trace queue operationseasy
- Using a JavaScript array as a stackeasy
- Cost of Array.shift in a queueeasy
- Cause of a stack overflow erroreasy
- Serving patients by severityeasy
- Data structure behind Undoeasy
- Browser back and forward buttonseasy
- Structure behind breadth-first searcheasy
- Depth-first search without recursioneasy
- Python queue: deque or listeasy
- What peek does on a stackeasy
- What stack underflow meanseasy
- Reversing a string with a stackeasy
- Building a stack on a linked listeasy
- Inserting at the head of a linked listeasy
- Reading the k-th node of a linked listeasy
- Deleting a known node in a doubly linked listeasy
- How a singly linked list endseasy
- Reversing a linked list in placeeasy
- Why use a dummy head nodeeasy
- Why arrays often beat linked listseasy
- Where the smallest value lives in a min-heapeasy
- Heap parent and child indiceseasy
- Cost of inserting into a binary heapeasy
- Cost of reading the top of a heapeasy
- Max-heap with Python heapqeasy
- Shape of a binary heapeasy
- Default order of Java PriorityQueueeasy
- Heap memory versus the heap data structureeasy
- What a deque supportseasy
- Checking a palindrome with a dequeeasy
- Round-robin scheduling with a queueeasy
- What a dead-letter queue is foreasy
- Keeping only the latest log lineseasy
- When arrivals outpace processingeasy
Medium 50
- Evaluate an expression with precedencemedium
- Decode a nested repeat stringmedium
- Evaluating a postfix expressionmedium
- Converting infix to postfixmedium
- Stack with O(1) getMinmedium
- Queue built from two stacksmedium
- Stack built from one queuemedium
- Capacity of a circular queuemedium
- Next write position in a ring buffermedium
- Next greater element with a stackmedium
- Days until a warmer temperaturemedium
- Are interleaved brackets valid?medium
- Simplifying a Unix pathmedium
- Stock span problemmedium
- Asteroid collision simulationmedium
- Removing adjacent duplicatesmedium
- Promise callback versus setTimeout ordermedium
- Which pop order is impossible?medium
- Evaluating a prefix expressionmedium
- Fewest brackets to add for validitymedium
- Next greater element in a circular arraymedium
- Detecting a cycle in a linked listmedium
- Finding where a cycle beginsmedium
- Middle node of an even-length listmedium
- Removing the n-th node from the endmedium
- Merging two sorted linked listsmedium
- Data structures behind an LRU cachemedium
- Deleting a node with no access to the headmedium
- Adding numbers stored as linked listsmedium
- Rotating a linked listmedium
- Building a heap from an arraymedium
- Top k largest with a small heapmedium
- Merging k sorted lists with a heapmedium
- Running median with two heapsmedium
- Trace an insert into a min-heapmedium
- Trace removing the minimum from a heapmedium
- Task scheduler with a cooldownmedium
- k-th largest value in a live streammedium
- Finding an arbitrary value in a heapmedium
- Rearranging letters so none repeatmedium
- Last stone weight with a max-heapmedium
- Grouping odd and even positions in a listmedium
- Josephus problem with a queuemedium
- Message order guarantee in Kafkamedium
- Why an SQS message is delivered twicemedium
- Handling at-least-once deliverymedium
- Bounded queue between producers and consumersmedium
- Preventing starvation in a priority queuemedium
- Rate limiter with a queue of timestampsmedium
- Average requests in a systemmedium
Hard 34
- Asteroid collisionhard
- Counting car fleets to a targethard
- Sliding window maximumhard
- Decoding a nested repeat stringhard
- Deep recursion on a skewed treehard
- Trapping rain waterhard
- Why doubling keeps push at O(1)hard
- Worst single dequeue in a two-stack queuehard
- Calculator with brackets and minushard
- Sum of subarray minimumshard
- Shortest subarray with sum at least Khard
- Iterative DFS visits in a different orderhard
- Longest valid parentheses substringhard
- Detecting a 132 pattern in O(n)hard
- Java Stack class or ArrayDequehard
- Palindrome check on a linked listhard
- Finding where two lists intersecthard
- Reordering a list from both endshard
- Reversing a linked list in groups of khard
- How a skip list gets fast searchhard
- Do circular links leak memory in JavaScript?hard
- Java LinkedList versus ArrayListhard
- Stale entries in Dijkstra's heaphard
- Supporting decrease-key in a binary heaphard
- Fibonacci heaps in real systemshard
- When a 4-ary heap beats a binary heaphard
- Equal priorities in Python heapqhard
- Cheapest way to join ropeshard
- Median of a sliding windowhard
- Reliable job queue on Redis listshard
- Backpressure in Node.js streamshard
- Managing millions of timershard
- Work-stealing deques in thread poolshard
- Promise loop that freezes timershard