Implement encoding validation and grid shortest path | Meta Interview Question