Question: Have a bug and need to fix it function solution(A, K) { var n = A.length; for (var i = 0; i < n -

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;

}

Step by Step Solution

3.31 Rating (151 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

function solutionA K var n Alength Asorta b a b Sort the ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Operating System Questions!