votes does.
You can cut the list after index i into two non-empty parts, votes[0..i] and votes[i+1..]. A cut is good if both parts have a leader and it is the same value.
Return the smallest index i that gives a good cut, or -1 if no cut is good.votes=[5, 4, 4, 5, 4, 4] → 2
Cutting after index 2 gives [5, 4, 4] and [5, 4, 4], and 4 takes 2 of 3 places in both. Cuts after indices 0 and 1 fail: [5] is led by 5 and [5, 4] has no leader at all.
votes=[2, 2, 2, 3, 3] → -1
Whatever the cut, 2 never takes more than half of the right part, so no cut works.
votes=[9] → -1
A single element cannot be cut into two non-empty parts.
votes has a leadervotes=[5, 4, 4, 5, 4, 4]
2
Run checks the first 3 tests in your browser. Submit checks all 11 tests on the server, hidden ones included.