Moogsoft Interview Question

DP, recursion