Re:Gaming CS Interviews
by orlp on Wednesday September 28, 2022 @05:59AM
(#33006251)
Not if you use a hash set. This is expected O(n) time to de-duplicate an array of integers while maintaining the original order (more explicitly written than I normally would in Rust for didactical purposes):
[ Parent
| on HN ]
Re:Gaming CS Interviews
by trinovantes on Wednesday September 28, 2022 @06:40AM
(#33006481)
Good point but it's not exactly a free lunch. You're trading memory for the speedup.
You can also use radix sort for what I'd like to call "fake" O(n) sort since physical hardware puts an upper limit on the hidden constant.