Function to get the missing element(Accolite, Adobe, Amazon, Cisco, D-E-Shaw, Intuit, Microsoft, Morgan Stanley, Ola Cabs, Payu, Qualcomm, Visa, Flipkart)

Suman Barik
0

#include <bits/stdc++.h>

using namespace std;


// Function to get the missing element

int getMissingNo(int a[], int n)

{

int i, total = 1;


for (i = 2; i <= (n + 1); i++) {

total += i;

total -= a[i - 2];

}

return total;

}


// Driver Program

int main()

{

int arr[] = { 1, 2, 3, 5 };

int N = sizeof(arr) / sizeof(arr[0]);


// Function call

cout << getMissingNo(arr, N);

return 0;

}


// This code is contributed by Aditya Kumar (adityakumar129)


Tags

Post a Comment

0Comments
Post a Comment (0)