전체 글 (212) 썸네일형 리스트형 코딜리티 lesson9 MaxProfit, MaxSliceSum, MaxDoubleSliceSum(?) MaxProfit [최초풀이] # you can write to stdout for debugging purposes, e.g. # print("this is a debug message") def solution(A): maxP = 0 for i in range(len(A)): for j in range(i+1, len(A)): if maxP < A[j]-A[i]: maxP = A[j]-A[i] return maxP [다른 풀이] # you can write to stdout for debugging purposes, e.g. # print("this is a debug message") def solution(A): if (len(A) == 1 ) or (len(A) == 0): return 0 mi.. 코딜리티 lesson8 Dominator, EquiLeader Dominator [최초풀이] # you can write to stdout for debugging purposes, e.g. # print("this is a debug message") def solution(A): if len(A) == 0: return -1 limitNum = len(A)/2 setA = set(A) ans = [] for x in setA: if A.count(x) > limitNum: ans.append(x) if len(ans) == 0: return -1 for y in ans: for i in range(len(A)): if y == A[i]: return i [다른풀이] # you can write to stdout for debugging purposes, e.g... 코딜리티 lesson7 Brackets, Fish(?), Nesting, StoneWall(?) Brackets [최초풀이] # you can write to stdout for debugging purposes, e.g. # print("this is a debug message") def solution(S): if len(S) == 0: return 1 if len(S) % 2 == 1: return 0 stack = [] for s in S: if s =='(' or s== '{' or s=='[': stack.append(s) elif s == ')': if len(stack) == 0: return 0 if stack.pop() != '(': return 0 elif s == '}': if len(stack) == 0: return 0 if stack.pop() != '{': return.. 이전 1 ··· 50 51 52 53 54 55 56 ··· 71 다음