Use stack to solve maze question