{"id":"d064141c-6527-4123-afe5-7d4a41a14f8b","name":"All Repeating Three Times Except One","description":"1. You are given an array of numbers.\r\n2. All numbers occur thrice in the array except one.\r\n3. You have to find the element that occurs once.","inputFormat":"A number n\r\na1\r\na2..\r\nn numbers","outputFormat":"A 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\n\nint solution(vector<int>& arr){\n \n}\n\n\nint main(){\n int n;\n cin>>n;\n \n vector<int>arr(n);\n \n for(int i=0;i<n;i++){\n cin>>arr[i];\n }\n \n cout<<solution(arr);\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 solution(arr);\r\n }\r\n\r\n public static void solution(int[] arr){\r\n //write your code here\r\n \r\n }\r\n\r\n}"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"4\r\n1 1 1 2 ","sampleOutput":"2","questionVideo":"https://www.youtube.com/embed/3gJxLkPPW6M?end=15","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":"12e92b2d-1bb1-4b75-8511-85df4ce4fde0","name":"All Repeating Three Times Except One","slug":"all-repeating-three-times-except-one","type":1}],"next":{"id":"98019ae2-3392-48e6-8191-d9e5b1730bc3","name":"All Repeating Three Times Except One MCQ","type":0,"slug":"all-repeating-three-times-except-one-mcq"},"prev":{"id":"9d6e860e-6c26-490f-adf2-c55bdba96c2a","name":"One Repeating and One Missing","type":3,"slug":"one-repeating-and-one-missing"}}}

All Repeating Three Times Except One

1. You are given an array of numbers. 2. All numbers occur thrice in the array except one. 3. You have to find the element that occurs once.

{"id":"d064141c-6527-4123-afe5-7d4a41a14f8b","name":"All Repeating Three Times Except One","description":"1. You are given an array of numbers.\r\n2. All numbers occur thrice in the array except one.\r\n3. You have to find the element that occurs once.","inputFormat":"A number n\r\na1\r\na2..\r\nn numbers","outputFormat":"A 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\n\nint solution(vector<int>& arr){\n \n}\n\n\nint main(){\n int n;\n cin>>n;\n \n vector<int>arr(n);\n \n for(int i=0;i<n;i++){\n cin>>arr[i];\n }\n \n cout<<solution(arr);\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 solution(arr);\r\n }\r\n\r\n public static void solution(int[] arr){\r\n //write your code here\r\n \r\n }\r\n\r\n}"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"4\r\n1 1 1 2 ","sampleOutput":"2","questionVideo":"https://www.youtube.com/embed/3gJxLkPPW6M?end=15","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":"12e92b2d-1bb1-4b75-8511-85df4ce4fde0","name":"All Repeating Three Times Except One","slug":"all-repeating-three-times-except-one","type":1}],"next":{"id":"98019ae2-3392-48e6-8191-d9e5b1730bc3","name":"All Repeating Three Times Except One MCQ","type":0,"slug":"all-repeating-three-times-except-one-mcq"},"prev":{"id":"9d6e860e-6c26-490f-adf2-c55bdba96c2a","name":"One Repeating and One Missing","type":3,"slug":"one-repeating-and-one-missing"}}}
plane

Editor


Loading...

All Repeating Three Times Except One

easy

1. You are given an array of numbers. 2. All numbers occur thrice in the array except one. 3. You have to find the element that occurs once.

Constraints

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

Format

Input

A number n a1 a2.. n numbers

Output

A number

Example

Sample Input

4 1 1 1 2

Sample Output

2

Question Video

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode