Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Notice that, <code>target</code> is either: A subarray of <code>nums</code>, or <code>prefix_sum[i]</code> + <code> k * sum(nums) </code> + <code>suffix_sum[j]</code> for some <code>i, j, k</code>.
You can solve the problem for those two separate cases using hash map and prefix sums.