If you want amortized complexity then a simple vector suffices.
If you want amortized complexity then a simple vector suffices.
2. The average complexity to search, insert, and delete data in a hash table is O(1), for interviews it works 99% of the time.
3. There is alternative O(1) solution you're looking for, I'll leave this exercise to you, bro. As well as the other exercise of being less toxic and a bit more respectful to people you don't know online lol.
I'm okay not getting 1% of the offers. I'm not $100 bill so everyone likes me.
I appreciate an attempt to educate me though, I wanted to make clear that any discussion like that is useless without solution to a problem. Post your solution, we'll discuss downsides. You can see it from my side, and I have another one. The parent commenter ain't got no solution, but keeps insisting he can implement that easily with this and that...
Good luck passing interviews with that attitude...
To be actually toxic for a moment, you do know that amortized and average are different right?
There is an easy solution to get O(1) for all operations too by allowing them to throw an exception: a simple array. There is no other O(1) solution for all operations that I am aware. In fact it is probably not too difficult to prove that such a solution does not exist.