Find the smallest split point where the same dominant value remains dominant in both parts of the array.
You are given an integer array nums. A split index i divides the array into two non-empty parts: nums[0..i] and nums[i+1..n-1].
A value is called the dominant value of a segment if it appears in more than half of the segment's elements.
Return the minimum split index i such that:
If no such split exists, return -1.
The array may contain repeated values, and the dominant value is not necessarily unique in the original array description, but if a valid split exists, the same value must dominate both sides.
nums of length n.i where 0 <= i < n - 1.nums[0..i]nums[i+1..n-1]i, or -1 if no valid split exists.2 <= nnums[i] are integers[0, n-2]Time/space constraints are not specified here; solve efficiently for large arrays.
Example 1
Input
nums = [1,2,2,2,3,2]
Output
1
Explanation
Split at index 1 gives left [1,2] and right [2,2,3,2]. The value 2 appears 1/2 times on the left? No, so this split is invalid. The minimum valid split is actually index 2: left [1,2,2] has 2 appearing 2/3 times, and right [2,3,2] has 2 appearing 2/3 times. So the answer is 2.
Example 2
Input
nums = [1,1,1,1]
Output
0
Explanation
Split at index 0 gives left [1] and right [1,1,1]. The value 1 dominates both parts, so the minimum valid split is 0.
Example 3
Input
nums = [1,2,3,4]
Output
-1
Explanation
No value can dominate both parts for any split.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.