Implement a hit counter for tracking requests in last 5 minutes.
Class Methods:
class HitCounter {
hit(timestamp: number): void
getHits(timestamp: number): number
}
Requirements:
Example: hit(10) hit(9) getHits(100) → 2 hit(201) getHits(400) → 2
Implement word transformation with shortest path finding.
Part 1: Basic Transformation Check if transformation possible from beginWord to endWord.
Part 2: Shortest Path Find length of shortest transformation sequence.
Example: beginWord = "hit" endWord = "cog" wordList = ["hot","dot","dog","lot","log","cog"] Output: 5 (hit→hot→dot→dog→cog)
Part 3: All Shortest Paths Find all possible shortest transformation sequences.