Better HN
topnewbestaskshowjobs
Log inSign up

Bossle

1 karma · joined Sep 13, 2019 (7y ago) · 1 submissions

Submissions

comment 7y ago · link · parent

Exactly, just truncate the iteration to the first k elements. Need a hash table to get the modified values, so it breaks the "O(1) extra space" condition, but that condition is bullshit anyway, you're already using O(k) space to store the numbers you find, an extra hash table is also O(k) space. http://ideone.com/5uwqNO