Trying to solve Maze Escape on HackerRank