all test cases are not passed when i use this code
But, when I add
if(book[i]>max){
return false;
}
in the for loop of isValid()
all the test cases are passed.
How can book[i] become > max
when start is maximum element of the array ?
all test cases are not passed when i use this code
But, when I add
if(book[i]>max){
return false;
}
in the for loop of isValid()
all the test cases are passed.
How can book[i] become > max
when start is maximum element of the array ?
This is included for a particular value of book array in which a particular element can become greater than wht is required ans, so for that You need to return false… If you carefully look at the video of book allocation, this is already explained their why this is valid case to include in your code…