Created
April 25, 2018 04:44
-
-
Save Kishy-nivas/c11a178db75390a78bb3f805beabdab0 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
def almostIncreasingSequence(sequence) | |
max = -100000 | |
mis_match = 0 | |
second_max = -10000 | |
sequence.each do |val| | |
if val > max | |
second_max = max | |
max = val | |
elsif val > second_max | |
max = val | |
mis_match +=1 | |
else | |
mis_match +=1 | |
end | |
end | |
return mis_match <=1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment