Samsung Electronics interview question

To write an algorithm that escapes a maze.