Split Array with Equal Averages
M · mediumP · Verified PYQarraysmath
Problem
Given an array of N integers, check if it can be split into two non-empty contiguous parts such that both parts have equal averages. Print “true” if possible, “false” otherwise.
Example
Input
4 1 2 3 4
Output
false
For each split point i (1 to n-1): check if leftSum*(n-i) == rightSum*i. If yes for any i, return true.