Stack

Level: Advanced

1. LFU Cache: Implement an LFU (Least Frequently Used) cache using a stack.
2. Maximum Frequency Stack: Design a maximum frequency stack that supports push, pop, and retrieving the most frequent element.
3. Remove Duplicate Letters to Form Smallest: Implement a function to remove duplicate letters to form the smallest lexicographical order string using a stack.
4. Crane Toy Game: Write a function to simulate a crane toy game using a stack.
5. Evaluate Expression Tree: Implement a function to evaluate an expression tree using a stack.
6. Sum of Subarray Minimums: Write a function to find the sum of subarray minimums using a stack.
7. Design a Stack with Increment Operation: Implement a stack that supports an increment operation.
8. Maximum Rectangle in Histogram: Write a function to find the maximum rectangle in a histogram using a stack.
9. Distant Barcodes: Implement a function to rearrange barcodes using a stack to avoid adjacent duplicates.
10. Brace Expansion II: Write a function to expand braces and generate all possible combinations using a stack.
11. Max Stack Operations: Implement a max stack that supports push, pop, top, peekMax, and popMax operations efficiently.
12. Shortest Subarray with Sum at Least K: Write a function to find the shortest subarray with a sum at least k using a stack.
13. Remove Duplicate Letters for Smallest Lexicographical Order: Implement a function to remove duplicate letters to achieve the smallest lexicographical order using a stack.
14. String Compression: Write a function to compress a string using a stack.
15. Construct Binary Tree from String with Brackets: Implement a function to construct a binary tree from a string with brackets using a stack.
16. Trapping Rain Water II: Write a function to solve the trapping rain water problem in 3D using a stack.
17. Sliding Window Maximum: Implement a function to find the maximum in each sliding window of size k using a stack.
18. Remove Invalid Parentheses: Write a function to remove the minimum number of invalid parentheses using a stack.
19. Basic Calculator IV: Implement a basic calculator that can evaluate expressions with nested parentheses and basic arithmetic using a stack.
20. Largest Rectangle Area in Histogram II: Write a function to find the largest rectangle area in a histogram with obstacles using a stack.
21. Decode String with Repetitions: Implement a function to decode a string with repetitions using a stack.
22. Partition Labels: Write a function to partition a string into as many parts as possible using a stack.
23. Maximum Sum of Subarray Minimums: Implement a function to find the maximum sum of subarray minimums using a stack.
24. Stack Sort: Write a function to sort a stack using another stack.
25. Tree Traversal using Stack: Implement tree traversal algorithms using a stack instead of recursion.

Beginner Level: View

Advanced Level: View