`{"id":"19593e49-63bb-4bb3-a557-8336a710bc87","name":"One Repeating And One Missing","description":"1. You are given an array of length n containing numbers from 1 to n.\r\n2. One number is present twice in array and one is missing.\r\n3. You have to find these two numbers.","inputFormat":"A number n\r\na1\r\na2..\r\nn numbers","outputFormat":"Missing number\r\nRepeating 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;\nvoid solution(vector<int> &v1)\n{\n \n}\nint main()\n{\n int n;cin>>n;\n vector<int> v1(n);\n for(int i=0;i<n;++i) cin>>v1[i];\n solution(v1);\n return 0;\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":"7\r\n1 \r\n3 \r\n4 \r\n5 \r\n1 \r\n6 \r\n2","sampleOutput":"Missing Number -> 7\r\nRepeating Number -> 1\r\n","questionVideo":"https://www.youtube.com/embed/MvklwzVz654?end=63","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":"9f970f36-deb7-413e-9082-b393da6aed43","name":"One Repeating And One Missing","slug":"one-repeating-and-one-missing","type":1}],"next":{"id":"ac97c236-1546-4784-8629-a85bfb668c2f","name":"One Repeating and One Missing MCQ","type":0,"slug":"one-repeating-and-one-missing-mcq"},"prev":{"id":"82c1b1b0-54fd-4a6b-a325-a15a631949f5","name":"All repeating except two","type":3,"slug":"all-repeating-except-two"}}}`

# One Repeating And One Missing

1. You are given an array of length n containing numbers from 1 to n. 2. One number is present twice in array and one is missing. 3. You have to find these two numbers.

`{"id":"19593e49-63bb-4bb3-a557-8336a710bc87","name":"One Repeating And One Missing","description":"1. You are given an array of length n containing numbers from 1 to n.\r\n2. One number is present twice in array and one is missing.\r\n3. You have to find these two numbers.","inputFormat":"A number n\r\na1\r\na2..\r\nn numbers","outputFormat":"Missing number\r\nRepeating 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;\nvoid solution(vector<int> &v1)\n{\n \n}\nint main()\n{\n int n;cin>>n;\n vector<int> v1(n);\n for(int i=0;i<n;++i) cin>>v1[i];\n solution(v1);\n return 0;\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":"7\r\n1 \r\n3 \r\n4 \r\n5 \r\n1 \r\n6 \r\n2","sampleOutput":"Missing Number -> 7\r\nRepeating Number -> 1\r\n","questionVideo":"https://www.youtube.com/embed/MvklwzVz654?end=63","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":"9f970f36-deb7-413e-9082-b393da6aed43","name":"One Repeating And One Missing","slug":"one-repeating-and-one-missing","type":1}],"next":{"id":"ac97c236-1546-4784-8629-a85bfb668c2f","name":"One Repeating and One Missing MCQ","type":0,"slug":"one-repeating-and-one-missing-mcq"},"prev":{"id":"82c1b1b0-54fd-4a6b-a325-a15a631949f5","name":"All repeating except two","type":3,"slug":"all-repeating-except-two"}}}` Editor

# One Repeating And One Missing

easy

1. You are given an array of length n containing numbers from 1 to n. 2. One number is present twice in array and one is missing. 3. You have to find these two numbers.

## Constraints

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

## Format

### Input

A number n a1 a2.. n numbers

### Output

Missing number Repeating Number

## 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;}7 1 3 4 5 1 6 2```

### 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;}Missing Number -> 7 Repeating Number -> 1 ```

Question Video

Discussions

Show Discussion

Related Resources 