Comments
On NaN7 → A little about DP, 8 years ago
+18

Ok, but we use DP anyway!

On NaN7 → A little about DP, 8 years ago
+18

We can handle it using supercomputers :))

On NaN7 → A little about DP, 8 years ago
+11

That's simple : dp[1][1]=2

update :

dp[0][0] = 0
dp[i][j]=dp[i][j-1]+1 if j>0
and
dp[i][j]=dp[i-1][j]+1 if i>0