Goldman Sachs Interview Question

do a leetcode styled reurrsion question