Vanshikapandey30 / Hacktoberfest2024

It's time to contribute to HacktoberFest 2024 :)
https://hacktoberfest.com
143 stars 752 forks source link

All O`one Data Structure #28

Closed Ash914027 closed 1 month ago

Ash914027 commented 1 month ago

All O`one Data Structure

Difficulty: Hard

Design a data structure to store the strings' count with the ability to return the strings with minimum and maximum counts.

Implement the AllOne class:

Note that each function must run in O(1) average time complexity.

 

Example 1:

Input
["AllOne", "inc", "inc", "getMaxKey", "getMinKey", "inc", "getMaxKey", "getMinKey"]
[[], ["hello"], ["hello"], [], [], ["leet"], [], []]
Output
[null, null, null, "hello", "hello", null, "hello", "leet"]

Explanation
AllOne allOne = new AllOne();
allOne.inc("hello");
allOne.inc("hello");
allOne.getMaxKey(); // return "hello"
allOne.getMinKey(); // return "hello"
allOne.inc("leet");
allOne.getMaxKey(); // return "hello"
allOne.getMinKey(); // return "leet"

 

Constraints:

Ash914027 commented 1 month ago

PLEASE ASSIGN TO ME WITH TAG HACTOBER FEST AND ACCEPT MY PULL REQUEST

Thejaggeddevil commented 1 month ago

Please assign this to me ,and add a hacktober fest tag.