public int solution(String s) {
int answer = 0;
char temp = s.charAt(0);
int num = 0;
int total = 0;
for (char c : s.toCharArray()) {
if (num * 2 == total) {
answer++;
temp = c;
}
if (c == temp) {
num++;
}
total++;
}
return answer;
}
출처:https://school.programmers.co.kr/learn/courses/30/lessons/140108