All Posts

Leetcode 703: Kth Largest Element in a Stream

You are tasked with implementing a class that helps track the kth highest score in a dynamic list of test scores. Each time a new score is submitted, you need to return the kth highest score in the list.

Leetcode 901: Online Stock Span

Design a system that processes daily stock price quotes and computes the price span for the current day. The price span for a day is defined as the maximum number of consecutive days (including today) where the price of the stock was less than or equal to today’s price.

Leetcode 1352: Product of the Last K Numbers

Design an algorithm that accepts a stream of integers and retrieves the product of the last k integers in the stream.

Leetcode 1472: Design Browser History

You are tasked with simulating the history of web page visits in a browser. Implement the BrowserHistory class to manage visit, back, and forward actions.

Leetcode 1656: Design an Ordered Stream

You are given a stream of n (id, value) pairs, where id is an integer between 1 and n, and value is a string. The task is to design a stream that returns the values in increasing order of their id. After each insertion, the stream should return the largest possible chunk of values that appear next in the order.

Leetcode 1670: Design Front Middle Back Queue

Design a queue that supports operations at the front, middle, and back. Implement the FrontMiddleBackQueue class with methods for adding and removing elements from these positions.