Advertisement
Guest User

Untitled

a guest
Aug 29th, 2014
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.35 KB | None | 0 0
  1. #include <algorithm>
  2. int solution(vector<int> &A) {
  3.     int N = A.size();
  4.     unsigned long long sum = 0;
  5.     for(unsigned int i = 0; i < A.size(); i++) {
  6.         if(A[i] != N+1) {
  7.             sum += A[i];
  8.         }
  9.     }
  10.    
  11.     unsigned long long sumShouldEqual = N * (N+1) / 2;
  12.     int result = sumShouldEqual - sum;
  13.     return result;
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement