fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int getMissingno(int a[],int n){
  4.  
  5. int N=n+1;
  6. int total=N*(N+1)/2;
  7. for(int i=0;i<n;i++)
  8. total-=a[i];
  9. return total;
  10. }
  11. int main() {
  12. // your code goes here
  13. int arr[]={1,2,4,5};
  14. int N=sizeof(arr)/sizeof(arr[0]);
  15. int miss=getMissingno( arr, N);
  16. cout<<miss;
  17. return 0;
  18. }
Success #stdin #stdout 0.01s 5380KB
stdin
Standard input is empty
stdout
3