Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
The sum of chosen elements will not be too large. Consider using a hash set to record all possible sums while iterating each row.
Instead of keeping track of all possible sums, since in each row, we are adding positive numbers, only keep those that can be a candidate, not exceeding the target by too much.