MCPcopy Create free account
hub / github.com/Vishruth-S/CompetitiveCode / main

Function main

HackerEarth_problems/Odd one out/solution.cpp:5–26  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3using namespace std;
4
5int main(){
6 int n, inp;
7 int x=0, y=0;
8
9 cin >> n;
10
11 /*
12 we capture the input numbers and add them in the variable x,
13 and add the odd numbers, we compare the two sums and find the missing number.
14 */
15 for(int i=1; i<n*2; i++){
16 if( i % 2 == 0){
17 cin >> inp;
18 x+=inp;
19 }else{
20
21 y+=i;
22 }
23 }
24 cout << y - x <<endl;
25 return 0;
26}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected