7. almostIncreasingSequence
def almostIncreasingSequence(sequence):
a = 0
for i in range(1, len(sequence)):
if i != 1 and i != len(sequence)-1:
#
if sequence[i-2] >= sequence[i] and sequence[i-1] >=sequence[i+1]:
a += 1
if sequence[i-1] == sequence[i]:
a += 1
elif sequence[i-1] > sequence[i]:
a +=1
return a < 2
'알고리즘' 카테고리의 다른 글
[알고리즘] 4/29 6. Make Array Consecutive 2 (0) | 2021.05.01 |
---|---|
[algorithm] Edge of the Ocean(adjacentElementsProduct/shapeArea) (0) | 2021.04.28 |
[algorithm] Intro (add / centuryFromYear / checkPalindrome) (0) | 2021.04.24 |
[알고리즘]단계별로 문제풀기 | if문 (백준/파이썬) (0) | 2021.03.19 |
[알고리즘] 알람시계(백준 2884/파이썬) (0) | 2021.03.19 |