Have a bug and need to fix it function solution(A, K) { var n = A.length; for
Fantastic news! We've Found the answer you've been seeking!
Question:
Have a bug and need to fix it
function solution(A, K) {
var n = A.length;
for (var i = 0; i < n - 1; i++) {
if (A[i] + 1 < A[i + 1])
return false;
}
if (A[0] != 1 && A[n - 1] != K)
return false;
else
return true;
}
Related Book For
Probability And Statistics
ISBN: 9780321500465
4th Edition
Authors: Morris H. DeGroot, Mark J. Schervish
Posted Date: