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.
Only really because the numbers themself are really bounded (<=10^5), so you can just allocate an array of 10^5 booleans (10kb) and use that as your data structure. Had the numbers been the full int range, for example, the space to allocate would have grown to ~2gb (or 4gb if negatives are allowed), which isn't really doable anymore.
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 →
Only really because the numbers themself are really bounded (<=10^5), so you can just allocate an array of 10^5 booleans (10kb) and use that as your data structure. Had the numbers been the full int range, for example, the space to allocate would have grown to ~2gb (or 4gb if negatives are allowed), which isn't really doable anymore.