24 views
22 Dec 2025
Design an LRU (Least Recently Used) Cache that supports get(key) and put(key, value) operations in constant time O(1). The cache should automatically remove the least recently accessed item when the c...
29 views
22 Dec 2025
Design a stack data structure that supports standard stack operations such as push, pop, and top, along with an additional operation getMin() that returns the minimum element present in the stack at a...
22 views
22 Dec 2025
Implement a Trie (Prefix Tree) data structure that supports insertion of words and searching for complete words as well as prefixes. Explain how the Trie improves search efficiency compared to a norma...
24 views
22 Dec 2025
Implement the Disjoint Set Union (Union-Find) data structure with path compression and union by rank. Explain how these optimizations reduce the time complexity of find and union operations in large d...
16 views
22 Dec 2025
Design and implement a Segment Tree to efficiently answer range sum queries on an array. The structure should also support point updates. Explain how segment trees divide the problem space and why the...
20 views
22 Dec 2025
Implement a Fenwick Tree (Binary Indexed Tree) to handle prefix sum queries and updates efficiently. Compare its performance and memory usage with a Segment Tree....
22 views
22 Dec 2025
Given an array and a window size k, design a data structure that efficiently finds the maximum element in every sliding window. Explain how a deque helps achieve linear time complexity....
15 views
22 Dec 2025
Implement a Priority Queue using a binary heap. Explain how insertion and deletion operations maintain the heap property and why heaps are suitable for priority-based processing....
20 views
22 Dec 2025
Design a data structure that continuously receives numbers from a data stream and returns the median at any time. Explain how two heaps can be used to balance the elements and compute the median effic...
24 views
22 Dec 2025
Explain the difference between LRU (Least Recently Used) and LFU (Least Frequently Used) caching strategies. Discuss scenarios where one strategy is preferred over the other and the data structures re...
23 views
22 Dec 2025
You are given an array of integers and need to handle two types of queries efficiently:
Range Update: Add a value to all elements in a given range [l, r]
Range Query: Find the minimum value in a...