11. Maximum Number of Non-Overlapping Subarrays With Sum Equals Target
Given an array nums
and an integer target
.
Return the maximum number of non-empty non-overlapping subarrays such that the sum of values in each subarray is equal to target
.
Solution:
Approach: Use prefix sum to check for all subarray with target sum Greedly check for maxEnd to prevent non overlapping intervals
Time Complexity: O(n) Space Complexity: O(n)
Last updated
Was this helpful?