Find the earliest level after which the first player has strictly more total points than the second player.
You are given an array possible of length n, where each value represents the outcome of a level:
1 means the first player gains a point on that level.0 means the second player gains a point on that level.Both players start with 0 points.
You need to determine the minimum number of levels the first player must complete so that, after those levels, the first player's score is strictly greater than the second player's score.
If this never happens, return -1.
In other words, find the smallest index k such that the sum of the first k elements is greater than the number of remaining 0s among those k elements.
possible.Each element is either 0 or 1.
-1 if no such prefix exists.1 <= possible.lengthpossible[i] is either 0 or 1Example 1
Input
possible = [0, 0, 1, 0, 1]
Output
3
Explanation
After 3 levels, the first player has 1 point and the second player has 2 points if we treat 1 as a point for the first player and 0 as a point for the second player. The earliest prefix where the first player becomes strictly ahead is after processing the first 3 levels in the intended scoring interpretation.
Example 2
Input
possible = [1, 1, 1]
Output
1
Explanation
After the first level, the first player already leads 1 to 0.
Example 3
Input
possible = [0, 0, 0]
Output
-1
Explanation
The first player never gets ahead.
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.