Goldman Sachs Interview Question

medium level LC- DP/DFS style question