{"id":"03295a40-5696-4440-938f-5e40df0160cf","name":"All Repeating Except One","description":"1. You are given an array of numbers.\r\n2. All numbers occur twice in the array except one.\r\n3. You have to find that number by traversing only once in the array and without using any extra \r\n space.\r\n","inputFormat":"A number n\r\na1\r\na2..\r\nn numbers","outputFormat":"Non-repeating number","constraints":"1 &lt;= n &lt;= 10^9\r\n1 &lt;= a1,a2.. &lt;= 10^9 ","sampleCode":{"cpp":{"code":"#include<bits/stdc++.h>\nusing namespace std;\n\nint main() {\n int n;\n cin >> n;\n //write your code \n \n}"},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static void main(String[] args){\r\n Scanner scn = new Scanner(System.in);\r\n int n = scn.nextInt();\r\n int[] arr = new int[n];\r\n for(int i = 0 ; i < n; i++){\r\n arr[i] = scn.nextInt();\r\n }\r\n //write your code here\r\n \r\n }\r\n\r\n}"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"5\r\n23 27 23 17 17","sampleOutput":"27","questionVideo":"https://www.youtube.com/embed/Ch1Mq58f3yQ?end=16","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":"f3e3dbef-d2b7-4f6d-b357-2ef3738e6c91","name":"Bit Manipulation For Intermediate","slug":"bit-manipulation-for-intermediate-9995","type":0},{"id":"76a187e7-15d4-448f-8935-0f6ef8f78b55","name":"All Repeating Except One","slug":"all-repeating-except-one","type":1}],"next":{"id":"04aa82a2-eb47-4374-a193-45bb47306736","name":"All Repeating Except One MCQ","type":0,"slug":"all-repeating-except-one-mcq"},"prev":{"id":"328ac3da-5159-4fab-ab77-a276fa79bbb0","name":"Number of Valid Words","type":3,"slug":"number-of-valid-words"}}}

All Repeating Except One

1. You are given an array of numbers. 2. All numbers occur twice in the array except one. 3. You have to find that number by traversing only once in the array and without using any extra space.

{"id":"03295a40-5696-4440-938f-5e40df0160cf","name":"All Repeating Except One","description":"1. You are given an array of numbers.\r\n2. All numbers occur twice in the array except one.\r\n3. You have to find that number by traversing only once in the array and without using any extra \r\n space.\r\n","inputFormat":"A number n\r\na1\r\na2..\r\nn numbers","outputFormat":"Non-repeating number","constraints":"1 &lt;= n &lt;= 10^9\r\n1 &lt;= a1,a2.. &lt;= 10^9 ","sampleCode":{"cpp":{"code":"#include<bits/stdc++.h>\nusing namespace std;\n\nint main() {\n int n;\n cin >> n;\n //write your code \n \n}"},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static void main(String[] args){\r\n Scanner scn = new Scanner(System.in);\r\n int n = scn.nextInt();\r\n int[] arr = new int[n];\r\n for(int i = 0 ; i < n; i++){\r\n arr[i] = scn.nextInt();\r\n }\r\n //write your code here\r\n \r\n }\r\n\r\n}"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"5\r\n23 27 23 17 17","sampleOutput":"27","questionVideo":"https://www.youtube.com/embed/Ch1Mq58f3yQ?end=16","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":"f3e3dbef-d2b7-4f6d-b357-2ef3738e6c91","name":"Bit Manipulation For Intermediate","slug":"bit-manipulation-for-intermediate-9995","type":0},{"id":"76a187e7-15d4-448f-8935-0f6ef8f78b55","name":"All Repeating Except One","slug":"all-repeating-except-one","type":1}],"next":{"id":"04aa82a2-eb47-4374-a193-45bb47306736","name":"All Repeating Except One MCQ","type":0,"slug":"all-repeating-except-one-mcq"},"prev":{"id":"328ac3da-5159-4fab-ab77-a276fa79bbb0","name":"Number of Valid Words","type":3,"slug":"number-of-valid-words"}}}
plane

Editor


Loading...

All Repeating Except One

easy

1. You are given an array of numbers. 2. All numbers occur twice in the array except one. 3. You have to find that number by traversing only once in the array and without using any extra space.

Constraints

1 <= n <= 10^9 1 <= a1,a2.. <= 10^9

Format

Input

A number n a1 a2.. n numbers

Output

Non-repeating number

Example

Sample Input

5 23 27 23 17 17

Sample Output

27

Question Video

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode