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.
if instead of an array list, you use a hash set, you can reduce the complexity down to O(n) because lookup in a hash set is a constant time operation instead of logarithmic or linear in your array ( depending if your array is sorted or not) .
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Cycle Detection
You are viewing a single comment's thread. Return to all comments →
if instead of an array list, you use a hash set, you can reduce the complexity down to O(n) because lookup in a hash set is a constant time operation instead of logarithmic or linear in your array ( depending if your array is sorted or not) .