메모장 입니다2

codility] Brackets 본문

Study/Programming

codility] Brackets

Wooum@n 2018. 1. 29. 01:18

https://app.codility.com/demo/results/trainingJ8R5PA-5X4/




def solution(S): # write your code in Python 3.6 sample = {"{": "}", "[": "]", "(": ")", "}": "{", "]": "[", ")": "("} list = [] ret = 1 second = int(len(S)-1) for x in range(len(S)): if (S[x] == "{") or (S[x] == "[") or (S[x] == "("): list.append(S[x]) else: if len(list) != 0: temp = list.pop() if temp != sample[S[x]]: ret= 0 break else: ret = 0 break if len(list) != 0: ret=0 return ret

'Study > Programming' 카테고리의 다른 글

Windows] 파일 맵핑  (0) 2018.01.30
project] 도서 관리  (0) 2018.01.30
알고리즘]  (0) 2018.01.26
JavaScript] checkbox, element 값 얻기  (0) 2017.12.12
JAVA] 현재 시간 구하기  (0) 2017.12.02