Solve work breaking in leetcode using DP.