import java.util.*;
class Solution {
public String solution(String s) {
String answer = "";
char [] ch = s.toCharArray();
Arrays.sort(ch);
char temp = ' ';
int cnt=0;
for(char c: ch){
if(c==temp)
{
cnt++;
}
else{
if(cnt==1)
{
answer+=temp;
}
temp=' ';
cnt=0;
temp=c;
cnt++;
}
}
if(cnt==1)
{
answer+=temp;
temp=' ';
cnt=0;
}
return answer;
}
}
'코딩테스트 > lv0' 카테고리의 다른 글
[프로그래머스 코딩테스트] java Lv.0 7의 개수 (0) | 2024.08.07 |
---|---|
[프로그래머스 코딩테스트] java Lv.0 k의 개수 (0) | 2024.08.07 |
[프로그래머스 코딩테스트] java Lv.0 숨어있는 숫자의 덧셈(2) (0) | 2024.08.06 |
[프로그래머스 코딩테스트] java Lv.0 A로 B 만들기 (0) | 2024.08.06 |
[프로그래머스 코딩테스트] java Lv.0 가까운 수 (0) | 2024.08.06 |