Facebook | Phone screen | Split array equal sum
Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2019-04-26Added By Anonymous
Source: Link
Company: Meta
Role: e3, e4
Interview Stage: Phone Screen
Location: unknown
Year: unknown
Original Post Content:
Position: Production Engineer
You're given an array made up of positive integers. Split the given array into two smaller arrays where the sums of each smaller array are equal. Print out the two smaller arrays.
eg.
[1,2,1,1,3] -> [1,2,1] & [1,3]
[1,1,1,1,1,5] -> [1,1,1,1,1] & [5]
[5,2,3] -> [5] & [2,3]
-> had to ask for clarification: print any arbitrary error message if the given array isn't splittable.