Problem: All O`one Data Structure
Understand how to design and implement the AllOne data structure that efficiently manages string keys with their counts. Explore the combination of a doubly linked list and hash maps to achieve average constant-time updates and queries for incrementing, decrementing, and retrieving keys with max or min frequency.
We'll cover the following...
Statement
Design a data structure that stores string keys along with their frequencies and supports efficient updates and queries.
Implement the AllOne class:
AllOne()→ Initializes the data structure.inc(key)→ Increases the count ofkeyby1. If the key does not exist, insert it with count1.dec(key)→ Decreases the count ofkeyby1. If the count becomes0, remove the key. It is guaranteed the key exists whendecis called.getMaxKey()→ Returns any key with the highest count. If empty, return""...