If you ever learnt programming in codeSignal, there are tests, and hidden tests. So my code is passing all the 19 tests, but the 34th hidden test is failed and I can't understand why, and I need some help. The problem is: 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.
bool almostIncreasingSequence(arr_integer sequence) {
int i, j, m, k, count, tmpArr[100];
bool incSeq;
count = 0;
for(i = 0; i < sequence.size; i++){
incSeq = true;
k = 0;
for(j = 0; j < sequence.size; j++){
if(i != j) {tmpArr[k] = sequence.arr[j]; k++;}
}
for(m = 1; m < sequence.size - 1; m++){
if(tmpArr[m-1] >= tmpArr[m]) { incSeq = false; break;}
}
if(incSeq) count++;
}
if(count > 0) return true;
else return false;
}
Aucun commentaire:
Enregistrer un commentaire