We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
The hashmap is really a good solution here, but want to mention that even in case of hashmap the complexity will be O(nlogn). This is because most of hashmaps are implemented using the self-balanced BST (mostly RB-tree) and the complexity for adding item to hashmap is O(logn).
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Hash Tables: Ice Cream Parlor
You are viewing a single comment's thread. Return to all comments →
The hashmap is really a good solution here, but want to mention that even in case of hashmap the complexity will be O(nlogn). This is because most of hashmaps are implemented using the self-balanced BST (mostly RB-tree) and the complexity for adding item to hashmap is O(logn).