Class Solution
-
- All Implemented Interfaces:
public final class Solution805 - Split Array With Same Average.
Hard
You are given an integer array
nums.You should move each element of
numsinto one of the two arraysAandBsuch thatAandBare non-empty, andaverage(A) == average(B).Return
trueif it is possible to achieve that andfalseotherwise.Note that for an array
arr,average(arr)is the sum of all the elements ofarrover the length ofarr.Example 1:
Input: nums = 1,2,3,4,5,6,7,8
Output: true
Explanation: We can split the array into 1,4,5,8 and 2,3,6,7, and both of them have an average of 4.5.
Example 2:
Input: nums = 3,1
Output: false
Constraints:
1 <= nums.length <= 30<code>0 <= numsi<= 10<sup>4</sup></code>
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
Modifier and Type Method Description final BooleansplitArraySameAverage(IntArray nums)-
-
Method Detail
-
splitArraySameAverage
final Boolean splitArraySameAverage(IntArray nums)
-
-
-
-