add a O(m*n) DP solution