[프로그래머스 2레벨] 문자열 압축 (C++)
#include #include #include using namespace std;int solution(string s) { int answer = s.size(); for(int i=1; i=2) result += to_string(cnt) + tmp; //다르면 누적된 문자열(숫자 + 문자) 저장 else result += tmp; //문자만 저장 tmp = s.substr(j, i); //새로운 문자열 시작 cnt = 1; } } // 남은 마지막 문자열 처리 if (cnt >= 2) result += to_string(cnt)..
프로그래머스/2레벨
2025. 3. 26. 22:01