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.
Not sure about Python, but the "g in n" in Java using a HashSet/Map would typically get O(1). Although it depends on the hashing algorithm used internally, but overall fetching from a HashSet/Map is considered as O(1). If the hashing is not good enough, it can turn out to be a O(n).
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Pairs
You are viewing a single comment's thread. Return to all comments →
Not sure about Python, but the "g in n" in Java using a HashSet/Map would typically get O(1). Although it depends on the hashing algorithm used internally, but overall fetching from a HashSet/Map is considered as O(1). If the hashing is not good enough, it can turn out to be a O(n).