Two Sigma interview question

Some recursion problem, likely leetcode hard