The second method is a little bit different than the first method, but it has a similar spirit. Solution 2 will involve a stack, but, we will not make use of a stack per se. Instead, we’ll use a Python list and its append and pop methods. These operations are similar to the push and pop methods of the stack data structure.