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!
32 stars 175 forks source link

All O`one Data Structure #207

Open Ash914027 opened 5 days ago

Ash914027 commented 5 days 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 5 days ago

PLEASE ASSIGN ME THIS PROBLEM AND ACCEPT MY PULL REQUEST

DevAffan commented 5 days ago

Sure, Done

Mohitbagul commented 5 days ago

Could you please assign me this issue