The subset sum to target

Only the last test case is not passing, it’s giving wa.
I’m using bottom-up approach.
Please check.

hello @prashantverma.vn
image

check the constraint in worst dp size can be upto 10^8.
so use linear dp.

how to use linear dp…??

u can refer this -> O(n)

I can’t understand the solution, can you please explain it a bit

I used it still the last test case is not passing

pls send me ur updated code using cb . ide , i will check

a) u were not reading n and sum.

b)
image
sign is not correct.it should be <=

ur updated code->

1 Like

Thanks for the help!!