A stack is a LIFO (last-in, first-out) data structure. The
core operations are push which adds an element to the stack
and pop with removes the top element of the stack.
Implement a Stack which can...
pushan element onto the stackpopremove the top element from the stack and return the elementcountthe number of elements on the stackpeekat the top element without removing itmaxfind the largest value in the stack
You can assume that this stack only holds integers.
While you can use a Ruby Array, don't use the following built-in
methods on Array:
push/<</unshiftpop/shiftmax/max_by/min/min_bycount/lengthfirst/last
And, for an added challenge, can you do it without using negative array indexes?