Computer Science, asked by nagoluhimachalapathi, 30 days ago


Mithali is developing a game in which the character makes their way through several
levels. In each level, if the character collects a star, the player scores a point. However, if a
level does not contain a star, the player loses a point. Player 1 always begins the game,
and, at some point, game play is turned over to Player 2 to complete the game. Player 1's
goal is to achieve a higher score than Player 2 once the game is completed. Given the
status of game levels (whether they contain a star or not), determine the minimum
number of levels Player 1 should play so that, in the end, their score is greater than Player
2's score.
1
N
Example
levels = [1, 1, 0, 1]
A
Player 1 has the following options:
Play Olevels. This would give them a score of 0. Player 2 would have a score of 3 - 1 = 2
(because they gain a point for each of the 3 levels with a star, and lose 1 point for the level
without a star).
Play 1 level. This would give them a score of 1. Player 2 would have a score of 2-1 = 1.
Play 2 levels. This would give them a score of 2. Player 2 would have a score of 1 - 1 = 0.
Only in this last case, by playing 2 levels, would Player 1's score be greater than Player 2's.
Therefore, return the answer 2.​

Answers

Answered by onitejaswi8
3

Answer:

okkkkkkkkk I will write it later and send it to you

Similar questions