[LeetCode] Minimum Levels to Gain More Points

3096. Minimum Levels to Gain More Points

You are given a binary array possible of length n.

Danielchandg and Bob are playing a game that consists of n levels. Some of the levels in the game are impossible to clear while others can always be cleared. In particular, if possible[i] == 0, then the ith level is impossible to clear for both the players. A player gains 1 point on clearing a level and loses 1 point if the player fails to clear it.

At the start of the game, Danielchandg will play some levels in the given order starting from the 0th level, after which Bob will play for the rest of the levels.

Danielchandg wants to know the minimum number of levels he should play to gain more points than Bob, if both players play optimally to maximize their points.

Return the minimum number of levels danielchandg should play to gain more points. If this is not possible, return -1.

Note that each player must play at least 1 level.

Read more
[LeetCode] Shortest Subarray With OR at Least K I

3095. Shortest Subarray With OR at Least K I

You are given an array nums of non-negative integers and an integer k.

An array is called special if the bitwise OR of all of its elements is at least k.

Return the length of the shortest special non-empty subarray of nums, or return -1 if no special subarray exists.

Read more
[AtCoder] G - Smaller SumRead more
[AtCoder] F - Negative Traveling SalesmanRead more
[AtCoder] F - Hop SugorokuRead more
[AtCoder] A - Shuffle and mod KRead more
[AtCoder] F - Christmas Present 2Read more
[Hacker Earth] Sherlock holmes and The temple MysteryRead more
[Hacker Earth] Lucky String JackpotRead more
[Hacker Earth] Roy and SweetsRead more