Created
September 9, 2018 03:25
-
-
Save oliverbth05/21ba63ad521d4217bc857e39471e5e7a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function almostIncreasingSequence(sequence) { | |
var i = 0; | |
var spliced; | |
function checkValid(arr) { | |
if (i > sequence.length) { | |
return false | |
} | |
let counter = 0; | |
for ( var j = 0 ; j < arr.length-1; j ++ ) { | |
if ( arr[j] < arr[j + 1] ) { | |
counter ++ | |
} | |
} | |
if ( counter === arr.length - 1) { | |
return true | |
} | |
else { | |
spliced = [...sequence]; | |
spliced.splice(i, 1); | |
i ++; | |
return checkValid(spliced); | |
} | |
} | |
return checkValid(sequence) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment