Goldman Sachs interview question

Technical: dynamic programming, recursion, arrays