링크 : https://school.programmers.co.kr/learn/courses/30/lessons/60057
#include <string>
#include <vector>
using namespace std;
int solution(string s) {
int answer = s.length();
for(int i = 1; i <= s.length()/2; i++){
string front = "", temp = "";
int cnt = 1;
front = s.substr(0,i);
for(int j = i; j < s.length(); j += i){
if(front == s.substr(j,i)) cnt++;
else{
if(cnt > 1) temp += to_string(cnt);
temp += front;
front = s.substr(j,i);
cnt = 1;
}
}
if(cnt > 1) temp += to_string(cnt);
temp += front;
if(answer > temp.size()) answer = temp.size();
}
return answer;
}