# 몇 번 반복되는지 카운트해야함
# 길이의 최소값을 리턴
def solution(s):
answer = 0
minTmp = len(s)
# 1부터 len/2 까지 자르기 가능
for i in range(1, len(s)//2 + 1):
tmpList = []
for j in range(0, len(s), i):
tmpList.append(s[j:j+i])
print(tmpList)
tmpStr = ""
tmpCnt = 1
for j in range(0, len(tmpList) - 1):
if(tmpList[j] == tmpList[j+1]):
tmpCnt += 1
if(j+1 == len(tmpList) -1):
tmpStr += str(tmpCnt)
tmpStr += tmpList[j]
else:
if tmpCnt > 1:
tmpStr += str(tmpCnt)
tmpStr += tmpList[j]
tmpCnt = 1
if(j+1 == len(tmpList) -1):
tmpStr += tmpList[j+1]
print(tmpStr)
minTmp = min(minTmp, len(tmpStr))
answer = minTmp
return answer
ref)
📌 memo
많은 도움이 되었습니다, 감사합니다.