Implement a Max Stack

Implement a Max Stack supporting the following operations:

  • push(x): Push integer x onto the top of the stack.
  • pop(): Remove and return the top element.
  • top(): Return the top element...

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: