#include <iostream>
#include <unordered_set>
bool array_contain_consecutive_integers(int arr[], int size) {
if (size <= 1) {
return true;
}
int min = arr[0], max = arr[0];
for (int i = 1; i < size; i++) {
if (arr[i] < min) {
min = arr[i];
}
if (arr[i] > max) {
max = arr[i];
}
}
if (max - min != size - 1) {
return false;
}
std::unordered_set<int> st;
for (int i = 0; i < size; i++) {
if (st.find(arr[i]) != st.end()) {
return false;
}
st.insert(arr[i]);
}
return true;
}
int main()
{
int arr[] = { -2, 3, 0, -1, 4, 2, 1 };
int size = sizeof(arr) / sizeof(arr[0]);
array_contain_consecutive_integers(arr, size)? std::cout << "Yes": std::cout << "No";
}
/*
run:
Yes
*/