Agoda interview question

Random Leetcode medium recursion question