목록문자열 압축 (1)
컴공생의 다이어리

[프로그래머스] 문자열 압축 - 파이썬(Python) def solution(s): answer = len(s) for step in range(1, len(s) // 2 + 1): comp = '' prev = s[0:step] count = 1 for i in range(step, len(s), step): if prev == s[i:i + step]: count += 1 else: comp += str(count) + prev if count >= 2 else prev prev = s[i:i + step] count = 1 comp += str(count) + prev if count >= 2 else prev answer = min(answer, len(comp)) return answer htt..
Development/Algorithm & Coding Test
2022. 6. 27. 00:01