Microsoft interview question

Round 4: Maze problem in leet code