Mark As Completed Discussion

number of ways to attain S without V is the value in the same column, but 1 row above, in our dynamic programming table.

number of ways to attain S-V with V is the value in the column V columns to the left, but 1 row above, in our dynamic programming table.

Therefore, in code, our final solution looks like this:

JAVA
OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment