ServiceNow interview question

Rat and maze problem based on dynamic programming