Skip to content


Last updated on September 26, 2019

Stack is like an array but it has limited functionality which only limits you to push and pop element into your stack. With push, you add a new element on top of the array while pop remove the element from the top and returns the first element of the stack.

Do take note that this only work with Int given the type being used here. If you would like to use extend it to allow all type, you may use generic in this case.

A stack is also a LIFO or last-in-first-out order. The element being pushed last is the first one to come off in the next pop.

Code Example

Published inAlgorithm

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Copyright © DaddyCoding 2020.