Google Interview Question

a simple brute force / obscure dp on coding challenge