How do i reduce it using dp?

hello @garganshul151
use memoization.
where ur dp state will be
dp[n][s]

what must i store in it?

ur answer.
ans.(that u r computing using r3cursion)

also how does it reduce complexity?

mean using this array how will it effect in optimization?

this problem has overlapping subproblem.
if we use only recursion then we will compute this sub problem more than once which will consume timee.

but by using array ,we r stroing answers of these subproblem so that we dont compute then again and save our time