Skip to content

Instantly share code, notes, and snippets.

@Underdoge
Created February 25, 2017 22:23
Show Gist options
  • Save Underdoge/378a21bc98f8175a7c40876e6584ab38 to your computer and use it in GitHub Desktop.
Save Underdoge/378a21bc98f8175a7c40876e6584ab38 to your computer and use it in GitHub Desktop.
almostIncreasingSequence
function almostIncreasingSequence(sequence){
var errors=0;
for(var i=0;i+1<sequence.length&&errors<2;i++)
if(sequence[i]>=sequence[i+1]){
errors++;
if(i+2<sequence.length&&i>0)
if(sequence[i]>=sequence[i+2])
errors++;
}
return errors<=1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment