Solve grid path and robot navigation | Meta Interview Question