Verily interview question

Recursive problems leetcode medium to hard