Vmware | Phone | subarray sum
Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2022-01-24Added By Anonymous
Source: Link
Given an array of integers, form three sub arrays s1, s2, s3 such that
sum(s2) <= sum(s1)+sum(s3).
Return the number of such subarrays that can be formed
Eg)
Input
[2,3,5,7]
Output
3
Explanation
subarrays are
•s1 = [2], s2 = [3], s3 = [5,7]
•s1 = [2,3], s2 = [5], s3 = [7]
•s1 = [2], s2 = [3,5], s3 = [7]