1477. Find Two Non-overlapping Sub-arrays Each With Target Sum
https://leetcode.com/problems/find-two-non-overlapping-sub-arrays-each-with-target-sum
Description
Given an array of integers arr
and an integer target
.
You have to find two non-overlapping sub-arrays of arr
each with a sum equal target
. There can be multiple answers so you have to find an answer where the sum of the lengths of the two sub-arrays is minimum.
Return the minimum sum of the lengths of the two required sub-arrays, or return -1
if you cannot find such two sub-arrays.
Example 1:
Example 2:
Example 3:
Example 4:
Example 5:
Constraints:
1 <= arr.length <= 105
1 <= arr[i] <= 1000
1 <= target <= 108
ac
Last updated