Facebook | Phone | Max Sum of Non-overlapping Subarray with Fixed Sum
Anonymous User
376

This question contains two part:

  1. Count the number of subarrays (continuous) whose sum equal to the given k.
  2. In all subarrays found above, find as many non-overlapping subarrays as possible that gives the maximal total sum. Output the total sum.

Q1 is Leetcode 560.
Q2 is new. Example:

[1,1,1], k = 2, there are 2 subarrays whose sum is 2, but they are overlapping.
So for Q2, output 2 instead of 4.
Comments (3)