Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.

Commit ad2c555

Browse files
committed
complete almostIncreasingSequnce
1 parent 18f28c6 commit ad2c555

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed
Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
function almostIncreasingSequence(sequence: number[]): boolean {
2-
2+
let count = 0;
3+
for (let i = 0; i < sequence.length; i++){
4+
if (sequence[i] <= sequence[i] - 1){
5+
count += 1;
6+
if (sequence[i] <= sequence[i - 2] && sequence[i + 1] <= sequence[i - 1]){
7+
return false;
8+
}
9+
}
10+
}
11+
return count <= 1;
312
}
413

5-
// console.log(almostIncreasingSequence([1, 3, 2, 1]))
6-
// console.log(almostIncreasingSequence([1, 3, 2]))
14+
console.log(almostIncreasingSequence([1, 3, 2, 1]))
15+
console.log(almostIncreasingSequence([1, 3, 2]))

0 commit comments

Comments
 (0)