Agoda Interview Question

I have Algorithms to solve