Skip to content

Latest commit

 

History

History
13 lines (8 loc) · 593 Bytes

043.md

File metadata and controls

13 lines (8 loc) · 593 Bytes

Daily Coding Problem: Problem #43 [Easy]

Good morning! Here's your coding interview problem for today.

This problem was asked by Amazon.

Implement a stack that has the following methods:

  • push(val), which pushes an element onto the stack
  • pop(), which pops off and returns the topmost element of the stack. If there are no elements in the stack, then it should throw an error or return null.
  • max(), which returns the maximum value in the stack currently. If there are no elements in the stack, then it should throw an error or return null.

Each method should run in constant time.