Agoda interview question

leet code problems with test case