Facebook | Phone | Max Sum of Non-overlapping Subarray with Fixed Sum
Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2020-07-23Added By Anonymous
Source: Link
Company: Meta (Facebook)
Role: e3, e4
Interview Stage: Phone Screen
Location: unknown
Year: unknown
Original Post Content:
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.