So this is javascript challenge I attempted in code signal.
Given a sequence of integers as an array, determine whether it is possible to obtain a strictly increasing sequence by removing no more than one element from the array
, i passed all the test but failed 1 of the hidden test and I am unsure why can anyone confirm this?. The hidden Test is an array containing [1-5000]. Hidden test output as “Empty”, expected to be “true”
this is my code and should logically work. Initially, I thought it has something to do with runtime but looking at the youtube breakdown, the runtime is about the same for the last test. Do you guys think its a bug?
function almostIncreasingSequence(sequence) {
if(isSequence(sequence)){ //if its sequence by default no need for further checks
return true;
}
for(let i = 0; i < sequence.length; i++){
var sliceCopy = sequence.slice(0);
sliceCopy.splice(i,1);
if(isSequence(sliceCopy)){
return true;
}
}
return false;
}
function isSequence(sequence){
for(var j = 0; j < sequence.length -1; j++){
if(sequence[j] >= sequence[j+1]){
return false;
}
}
return true;
}