Comments

yes, this is a possibility, but the question states that both of them make the best move possible, if bob flips then it is a draw, if he doesn't then he wins

Alice has no such option available to her

If no of 0s is 4 (even)

0000

Alice spends 0100

Bob spends 0110

Alice spends 1110

Bob reverses 0111

Alice spends 1111

Bob wins

If no of 0s is 5 (odd)

00000

Alice spends 00100

Bob spends 00101

Alice spends 10101

Bob spends 11101

Alice reverses 10111

Bob spends 11111

Alice wins

Hope it helps !

In A, 2^msb can also be calculated using log

int msb = (int)(Math.log(n)/Math.log(2));

Thanks buddy

Is the solution only given in C++ ? If no, when will Java solutions be uploaded ?

Competitive Programming is not viewed as a sport, it is seen as a part of academics. Think about it, why don't people come and watch IMO ? You can watch people solve theorems/problems, because no one wants to use their brains when enjoying something.

Also, the thing with other e-sports and physical sports is that it is fun to watch. Watching people play football or pubg is more fun than watching someone struggle to find that error in their code.