Added 2-array DP solution