Tap here to switch tabs
Problem
Submissions

Problem: Minimum Levels to Gain More Points

Try to solve the Minimum Levels to Gain More Points problem.

Statement

You are given a binary array possible of length n.

Alice and Bob are playing a game consisting of n levels in order. Each level i is represented by possible[i]:

  • If possible[i] == 1, the player who plays level i gains 11 point.

  • If possible[i] == 0, the player who plays level i loses 11 point.

Alice plays first and completes a prefix of the levels. Bob then plays the remaining levels to the end. Both Alice and Bob must play at least 11 level.

Return the minimum number of levels Alice must play to earn strictly more total points than Bob. If it is impossible for Alice to obtain more points than Bob, return −1-1.

Constraints:

  • 2≤n=2 \leq n = possible.length ≤105\leq 10^5

  • possible[i] is either 00 or 11.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Levels to Gain More Points

Try to solve the Minimum Levels to Gain More Points problem.

Statement

You are given a binary array possible of length n.

Alice and Bob are playing a game consisting of n levels in order. Each level i is represented by possible[i]:

  • If possible[i] == 1, the player who plays level i gains 11 point.

  • If possible[i] == 0, the player who plays level i loses 11 point.

Alice plays first and completes a prefix of the levels. Bob then plays the remaining levels to the end. Both Alice and Bob must play at least 11 level.

Return the minimum number of levels Alice must play to earn strictly more total points than Bob. If it is impossible for Alice to obtain more points than Bob, return −1-1.

Constraints:

  • 2≤n=2 \leq n = possible.length ≤105\leq 10^5

  • possible[i] is either 00 or 11.