Tuesday C++ common interview problem.
Implement a Max-Stack data structure that provides the following interface:
O(1) complexity methods: top() and max()
O(logn) complexity methods: push(), pop() and pop_max()
Solve it yourself: https://compiler-explorer.com/z/4bd3qGxd3
Solution: https://compiler-explorer.com/z/8aTxGe1bK
@simontoth Is throwing an std::vector at it a valid solution?
@Mek101 Well, yes, since you can do almost anything with a std::vector, but you will need a way to achieve O(logn).