Computer Science/알고리즘 ( Algorithm )

Codility - Nesting

bugtype 2019. 3. 11. 21:01


def solution(S): # write your code in Python 3.6 if len(S) == 0: return 1 if len(S) == 1: return 0 stack = [] for char in S: if char=="(": stack.append(char) else: if len(stack) > 0: stack.pop() else: return 0 if len(stack) > 0: return 0 return 1

'Computer Science > 알고리즘 ( Algorithm )' 카테고리의 다른 글

Codility - OddOccurrencesInArray  (0) 2019.03.12
Codility - StoneWall  (0) 2019.03.11
Codility - CyclicRotation  (0) 2019.03.11
Codility - Binary gap  (0) 2019.03.11
카카오 오픈채팅방  (0) 2019.01.30