Implemented brute-force and DP model for solving.