Design
LeetCode 703: Kth Largest Element in a Stream
·1 min
LeetCode
Easy
Tree
Design
Binary-Search-Tree
Heap-Priority-Queue
LeetCode 703 note: keep a min-heap of size k; its top is the k-th largest
LeetCode 232: Implement Queue using Stacks
·1 min
LeetCode
Easy
Stack
Design
Queue
LeetCode 232 note: two stacks, where in receives pushes and out is refilled from in only when empty, amortized O(1)
LeetCode 225: Implement Stack using Queues
·2 mins
LeetCode
Easy
Stack
Design
Queue
LeetCode 225 note: one queue suffices: after a push, rotate all earlier elements to the back so the new element sits at the front