add 1D DP array solution