DP solution to numDecodings