boolean almostIncreasingSequence(int[] sequence) {
int prev = sequence[0];
boolean usedMyChance = false;
boolean rightbreak = true;
for (int i = 1; i < sequence.length; i++) {
if (sequence[i] <= prev) {
if (usedMyChance) {rightbreak = false;break;}
usedMyChance = true;
if (i == 1) prev = sequence[i];
} else {
prev = sequence[i];
}
}
prev = sequence[sequence.length - 1];
usedMyChance = false;
boolean leftbreak = true;
for (int i = sequence.length - 2; i >= 0; i--) {
if (sequence[i] >= prev) {
if (usedMyChance) {leftbreak = false;break;}
usedMyChance = true;
if (i == sequence.length - 2) prev = sequence[i];
} else {
prev = sequence[i];
}
}
return rightbreak || leftbreak;
}