AKUNA CAPITAL Interview Question

A graph question which was solved using DFS and design elevator system