Optiver interview question

Question about optimisation of graph searching