def solution(H): # write your code in Python 3.6 stack = [] count = 0 for x in H: while(len(stack)>0 and stack[len(stack)-1] > x): stack.pop() if len(stack)==0 or stack[len(stack)-1] < x: stack.append(x) count+=1 return count pass
'Computer Science > 알고리즘 ( Algorithm )' 카테고리의 다른 글
프로그래머스 - 게임 맵 최단거리 (0) | 2019.03.14 |
---|---|
Codility - OddOccurrencesInArray (0) | 2019.03.12 |
Codility - Nesting (0) | 2019.03.11 |
Codility - CyclicRotation (0) | 2019.03.11 |
Codility - Binary gap (0) | 2019.03.11 |