-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPermCheck.cpp
More file actions
39 lines (36 loc) · 911 Bytes
/
PermCheck.cpp
File metadata and controls
39 lines (36 loc) · 911 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// you can use includes, for example:
#include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
int solution(vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int>::iterator it;
//int missing_element = A.size();
int x = *std::min_element(A.begin(), A.end());
sort(A.begin(), A.end());
for (vector<int>::const_iterator i = A.begin(); i != A.end(); ++i)
{
//cout << x << " " << *i << endl;
if(*i != x)
{
return 0;
}
x++;
}
return 1;
//cout << start << endl;
/*for(unsigned int i = start;i < (A.size() + 1);i++)
{
it = find (A.begin(), A.end(), i);
if (it == A.end())
missing_element = i;
}
if(missing_element == A.size())
{
return 1;
}
else
{
return 0;
}*/
}