All Posts

Leetcode 1600: Throne Inheritance

In a kingdom, there is a well-defined hierarchy of inheritance, starting with the king. The inheritance order depends on the family’s birth and death events. Implement a class to keep track of the order, excluding the dead members.

Leetcode 1603: Design Parking System

You are tasked with designing a parking system for a parking lot that has three types of parking spaces: large, medium, and small. Each type of parking space has a fixed number of available slots. Your goal is to implement the ParkingSystem class that supports the operations of initializing the parking system and parking a car based on its type.

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.

Leetcode 1797: Design Authentication Manager

You are tasked with creating an authentication system that handles tokens. Each token has an expiration time, and a user can generate new tokens or renew existing ones before they expire. The system should track and count the number of unexpired tokens at any given time.

Leetcode 1845: Seat Reservation Manager

Design a system to manage the reservation state of n seats numbered from 1 to n. Implement the SeatManager class to handle reserving and unreserving seats. The class should be able to return the smallest available seat when reserved, and make seats available again when unreserved.