DevAffan / AffiCodes-Hacktoberfest2024

Make your first Pull Request for Hacktoberfest 2024! Don’t forget to spread the love, and if you find it helpful, consider giving us a ⭐️. This repository includes useful algorithms and code to help beginners, featuring multiple languages and ideas. You’ll also find some beginner-friendly mini projects to get you started!
40 stars 294 forks source link

All O`one Data Structure #207

Open Ash914027 opened 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 ME THIS PROBLEM AND ACCEPT MY PULL REQUEST

DevAffan commented 1 month ago

Sure, Done

Mohitbagul commented 1 month ago

Could you please assign me this issue