implement a brute force solution and a dynamic programming solution.