230804 문자열 나누기

Jongleee·2023년 8월 4일
0

TIL

목록 보기
329/576
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

0개의 댓글