`{"id":"825e16b1-368f-4fd6-8ae7-8a37a96ff6c8","name":"Winner In Nim Game","description":"Given an array of integers, two players Alice and Bob are playing a game where Alice can remove any element from the array.If the bitwise XOR of all remaining elements equals 0 after removal of selected element, then that player looses.Find out winner if both of the players play optimally. Alice starts the game first. In case case one-element in array consider its value as the XOR of array","inputFormat":"The first line contains integer n, no. of integers.\r\nsecond line contains n integers arr[1],arr[2]...arr[n].","outputFormat":"Print the winner (Alice or Bob).","constraints":"1&lt;= n &lt;= 10^5\r\n1&lt;= arr[i] &lt;= 10^8","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.io.BufferedReader;\r\nimport java.io.IOException;\r\nimport java.io.InputStreamReader;\r\n\r\npublic class Main {\r\n static String findWinner(int[] arr, int n) {\r\n\r\n }\r\n\r\n public static void main(String[] args) throws NumberFormatException, IOException {\r\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\r\n int n = Integer.parseInt(br.readLine());\r\n int[] arr = new int[n];\r\n String[] st = br.readLine().split(\" \");\r\n\r\n for (int i = 0; i < n; i++) {\r\n arr[i] = Integer.parseInt(st[i]);\r\n }\r\n\r\n System.out.println(findWinner(arr, n));\r\n }\r\n}"},"ruby":{"code":""},"python":{"code":""},"javascript":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"5\r\n15 6 9 10 20","sampleOutput":"Bob\r\n","questionVideo":"","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"1191e2be-22c8-444b-988f-201dc78b143e","name":"Game Theory For Experts","slug":"game-theory-for-experts-930","type":0},{"id":"907e8e95-4e3d-42f0-a0f0-ed129a6f7864","name":"Winner In Nim Game","slug":"winner-in-nim-game","type":1}],"next":{"id":"2ad5b04e-e941-400c-906f-c74f902a71bd","name":"Number Game","type":1,"slug":"number-game"},"prev":{"id":"e4f114f9-46b2-4ae6-a6e8-726cf566c0be","name":"A Modified Game Of Nim","type":1,"slug":"a-modified-game-of-nim"}}}`

Winner In Nim Game

Given an array of integers, two players Alice and Bob are playing a game where Alice can remove any element from the array.If the bitwise XOR of all remaining elements equals 0 after removal of selected element, then that player looses.Find out winner if both of the players play optimally. Alice starts the game first. In case case one-element in array consider its value as the XOR of array

`{"id":"825e16b1-368f-4fd6-8ae7-8a37a96ff6c8","name":"Winner In Nim Game","description":"Given an array of integers, two players Alice and Bob are playing a game where Alice can remove any element from the array.If the bitwise XOR of all remaining elements equals 0 after removal of selected element, then that player looses.Find out winner if both of the players play optimally. Alice starts the game first. In case case one-element in array consider its value as the XOR of array","inputFormat":"The first line contains integer n, no. of integers.\r\nsecond line contains n integers arr[1],arr[2]...arr[n].","outputFormat":"Print the winner (Alice or Bob).","constraints":"1&lt;= n &lt;= 10^5\r\n1&lt;= arr[i] &lt;= 10^8","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.io.BufferedReader;\r\nimport java.io.IOException;\r\nimport java.io.InputStreamReader;\r\n\r\npublic class Main {\r\n static String findWinner(int[] arr, int n) {\r\n\r\n }\r\n\r\n public static void main(String[] args) throws NumberFormatException, IOException {\r\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\r\n int n = Integer.parseInt(br.readLine());\r\n int[] arr = new int[n];\r\n String[] st = br.readLine().split(\" \");\r\n\r\n for (int i = 0; i < n; i++) {\r\n arr[i] = Integer.parseInt(st[i]);\r\n }\r\n\r\n System.out.println(findWinner(arr, n));\r\n }\r\n}"},"ruby":{"code":""},"python":{"code":""},"javascript":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"5\r\n15 6 9 10 20","sampleOutput":"Bob\r\n","questionVideo":"","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"1191e2be-22c8-444b-988f-201dc78b143e","name":"Game Theory For Experts","slug":"game-theory-for-experts-930","type":0},{"id":"907e8e95-4e3d-42f0-a0f0-ed129a6f7864","name":"Winner In Nim Game","slug":"winner-in-nim-game","type":1}],"next":{"id":"2ad5b04e-e941-400c-906f-c74f902a71bd","name":"Number Game","type":1,"slug":"number-game"},"prev":{"id":"e4f114f9-46b2-4ae6-a6e8-726cf566c0be","name":"A Modified Game Of Nim","type":1,"slug":"a-modified-game-of-nim"}}}`

Editor

Winner In Nim Game

medium

Given an array of integers, two players Alice and Bob are playing a game where Alice can remove any element from the array.If the bitwise XOR of all remaining elements equals 0 after removal of selected element, then that player looses.Find out winner if both of the players play optimally. Alice starts the game first. In case case one-element in array consider its value as the XOR of array

Constraints

1<= n <= 10^5 1<= arr[i] <= 10^8

Format

Input

The first line contains integer n, no. of integers. second line contains n integers arr[1],arr[2]...arr[n].

Output

Print the winner (Alice or Bob).

Example

Sample Input

```.css-23h8hz{color:inherit;font-size:0.875rem;line-height:1.125rem;letter-spacing:0.016rem;font-weight:var(--chakra-fontWeights-normal);white-space:pre-wrap;}5 15 6 9 10 20```

Sample Output

```.css-3oaykw{color:var(--chakra-colors-active-primary);font-size:0.875rem;line-height:1.125rem;letter-spacing:0.016rem;font-weight:var(--chakra-fontWeights-normal);white-space:pre-wrap;font-family:Monospace;}Bob ```

Discussions

Show Discussion

Related Resources