Skip to content

Comment on StableCodeparent

Comments

Pointing out a mistake is toxicity? Your ego is off the charts. Also, I gave you a solution that would probably be _better_ than yours in 99% of scenarios, a simple vector from any standard library, std::vector in C++, and Vec in Rust. This solution gives you O(1) worst case for peek, and amortized worst case O(1) for the other operations.

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.

If your interviewer is asking for solution and you keep insisting that "I have you a solution"... without actual code... Also saying my ego is off the charts. Good luck passing interviews with that attitude.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.