function array_contain_consecutive_integers(arr) {
if (arr.length <= 1) {
return true;
}
let min = arr[0];
let max = arr[0];
for (const val of arr) {
if (val < min) {
min = val;
}
if (val > max) {
max = val;
}
}
if (max - min != arr.length - 1) {
return false;
}
let st = new Set();
for (const val of arr) {
if (st.has(val)) {
return false;
}
st.add(val);
}
return true;
}
const arr = [-2, 3, 6, 0, -1, 4, 2, 5, 1];
if (array_contain_consecutive_integers(arr)) {
console.log("Yes");
}
else {
console.log("No");
}
/*
run:
Yes
*/