Deviopath › Go

Stack

Medium · Data Structures

A stack is last-in first-out. Implement Push, Pop, and Peek on Stack. Pop and Peek on an empty stack return 0, false. RunStack(ops) is already written: each op is "push N", "pop", or "peek" and the function returns every popped or peeked value (0 when ok is false, plus a following 0 or 1 for ok).

Next: Wrap an Error