Agoda interview question

I have Algorithms to solve