function solution(A) {
A.sort((l, r) => l - r);
if (A[0] !== 1) {
return 0;
}
for (let i = 0; i < A.length - 1; i++) {
if (A[i + 1] - A[i] !== 1) {
return 0;
}
}
return 1;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A) {
// write your code in JavaScript (Node.js 8.9.4)
A.sort((a,b) => a - b)
for(i = 0; i < A.length; i += 2){
if(A[i]+1 != A[i + 1]){
return 0;
}
}
return 1;
}
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
A.sort()
if A[0] != 1:
return 0
for i in range(len(A) - 1):
if (A[i + 1] - A[i]) != 1:
return 0
return 1