Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Keep track of prefix sums to quickly look up what subarray that sums "target" can be formed at each step of scanning the input array.
It can be proved that greedily forming valid subarrays as soon as one is found is optimal.