Given a circular array arr[] of size N containing positive integers only, Player A and B are playing a game, turn by turn, the game will start with player A at index 0 and then player B at the next index.
 In every turn a player can deduct some value from arr[i] and decrease the value of an element arr[i] to X ( 0 to arr[i]1 ).
 Then, other player turn will come and he/she will do the same with the next element in right circular order.
If a player cannot decrease the value of the element then he/she loses. Find if A and B play optimally, who will win?
Note: In each turn, a player moves to a new position than his/her previous position.
Examples:
Input: arr[] = {1, 2, 4, 3}
Output: B
Explanation: A have to deduct 1 from 1,
Now it’s B turn, B deduct whatever from 2,
Again, A deduct whatever from index 3,
Again, B deduct whatever from index 4,
Now, it’s A turn, and A is on index 0, and index 0th element is 0.
So, A will lose, B win.Input: arr[] = {5}
Output: A
Explanation: A will decrease the value of arr[i]( 5 ) to 0.
So, for B the number become 0 and B will lose, A win.
Approach: To solve the problem follow the below idea:
The idea is, A only remove some amount from even indexed integers and B only remove some amount from odd indexed integers.
If N = odd, A will always win because
 A will remove all the amount from index 0 element making the number = 0,
 Now the other numbers whatever maybe and whatever amount will both of them remove from them, the thing is, B will always come to 0th indexed element i.e., 0, after one rotation, So, B will loose for sure,
But for N = Even, we check in what position the minimum element occur, even or odd, because
 The optimal startegy is that every one remove 1 unit from their parity element.
 And in whichever parity the first time minimum element will occur that parity element will become 0 for the first time and the player will lose and other parity element will win.
Follow the below steps to solve the problem:
 If N is Odd, A will win for sure, so just print A.
 Else find position of the first minimum element in the arr[].
 If the position is even A will win.
 Else B will win.
Below is the implementation of the above approach.
C++

Time Complexity: O(N)
Auxiliary Space: O(1)