IT/coding study 44

[acmicpc] 3020. 개똥벌레 (python)

구간합 알고리즘 import sys input=sys.stdin.readline n, h = map(int, input().split(" ")) down = [0] * h # 석순 up = [0] * h # 종유석 for i in range(n): end=int(input())-1 if i%2==0: down[end]+=1 else: up[end]+=1 for i in range(h - 2, -1, -1): down[i] += down[i + 1] up[i] += up[i + 1] down.reverse() result=[] for j in range(len(down)): result.append(down[j]+up[j]) # 각 높이마다 장애물 합 mins=min(result) cnt=result.co..

IT/coding study 2022.03.10

[programmers] [3차] 압축 (python)

2018 KAKAO BLIND RECRUITMENT - queue와 list사용 from collections import deque def solution(msg): answer = [] dics = [] que=deque(msg) dics=[chr(i) for i in range(ord('A'),ord('Z')+1)] #A:0,B:1,.. tmp='' while len(que)>0: tmp='' for _ in range(0,len(que)): tmp+=que[0] if tmp in dics: que.popleft() else: #사전에 포함이 안될 때 answer.append(dics.index(tmp[:-1])+1) #사전에 포함안되는 문자는 빼기 dics.append(tmp) break answ..

IT/coding study 2022.01.18