Using stacks is convenient, but there is a memory cost - since the taller the stack is, higher the memory requirements.
The alternatives to overcome that are 2: