All Posts

Leetcode 146: LRU Cache

Design and implement an LRU (Least Recently Used) cache. The cache should support two operations: get(key) and put(key, value). Both operations must run in O(1) time on average. If the cache exceeds its capacity, the least recently used key should be evicted.

Leetcode 155: Min Stack

Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.

Leetcode 208: Implement Trie (Prefix Tree)

Implement a Trie data structure that supports inserting words, searching for exact matches, and checking if any word starts with a given prefix.

Leetcode 211: Design Add and Search Words Data Structure

You are tasked with creating a data structure that allows adding words and checking if a word matches any previously added word, with support for the wildcard ‘.’ character.

Leetcode 225: Implement Stack using Queues

Design a stack that supports LIFO (Last In First Out) operations using only one queue. Implement standard stack operations: push, pop, top, and empty.

Leetcode 232: Implement Queue using Stacks

Design and implement a queue using only two stacks. The queue should support the basic operations of a normal queue: enqueue, dequeue, peek, and checking if the queue is empty.