#include <iostream>
#include <string>
#include <vector>
using namespace std;
int solution(string s)
{
int answer = 2147483647i32;
int size = s.size();
for (int i = 1; i <= size; i++)
{
string sub = s.substr(0, i);
int loop = size / i;
string comp;
string value = "";
int check = 1;
for (int j = 1; j <= loop; j++)
{
comp = s.substr(i*j, i);
if (sub == comp)
{
check++;
}
else
{
if (check != 1)
{
value += std::to_string(check);
check = 1;
}
value += sub;
sub = comp;
}
}
value += sub;
cout << value << endl;
if (answer > value.size())
{
answer = value.size();
}
}
return answer;
}
algorithm/2020 KAKAO BLIND
댓글