프로그래머스 - 문자열 압축


프로그래머스 - 문자열 압축

def solution(s): answer = [] for i in range(1,len(s)+1): data = [] tmp = "" for j in range(len(s)): tmp += s[j] if len(tmp) == i: data.append(tmp) tmp = "" if len(tmp): data.append(tmp) tmp = "" data.append([]) cnt = 1 check = data[0] tmp2 = "" for j in range(1,len(data)): if len(data) == 1: break if data[j] == check: cnt +=1 else: if cnt == 1: tmp2 += check check = data[j] else: tmp2 += str(cnt) + check check = data[j] cnt = 1 answer.append(len(tmp2)) return min(answer) Colored by Color Scriptercs...



원문링크 : 프로그래머스 - 문자열 압축