News for hackers. Stuff that matters.
Re:Gaming CS Interviews by Cyphonetic on Wednesday September 28, 2022 @06:27AM (#33006415)
But to order a list is O(n log n)
Re:Gaming CS Interviews by trinovantes on Wednesday September 28, 2022 @06:42AM (#33006493)
In the worst case, you need to insert every element into your set to find out if there's no duplicate hence it'll take O(n log n) too
Re:Gaming CS Interviews by pclmulqdq on Wednesday September 28, 2022 @02:42PM (#33011618)
Not with a hash set - that gives you expected amortized O(1) insertion (yes, both expected and amortized). In contrast, a generalized sort is O(n log n), but you can sort numeric types in O(n).