728x90
반응형
SMALL
문자의 중복을 없애고 순서대로 정답에 더하면 끝!
import java.util.*;
import java.util.stream.Collectors;
public class Main {
public static void main(String[] args){
Scanner in=new Scanner(System.in);
String target = in.nextLine();
String answer = "";
List<Character> arr = new ArrayList<>();
for(int i=0; i<target.length(); i++){
arr.add(target.charAt(i));
}
List<Character> collect = arr.stream().distinct().collect(Collectors.toList());
for (Character c : collect) {
answer += c;
}
System.out.println(answer);
}
}
728x90
반응형
SMALL
'문제 풀이 > 백준 문제풀이' 카테고리의 다른 글
팰린드롬(회문 문자열) (0) | 2023.12.10 |
---|---|
회문문자열 (0) | 2023.12.10 |
백준 문제 풀이[10951번] JavaScript A+B-4 (Buffer사용법) (0) | 2023.01.24 |
백준 문제 풀이[2939번] JavaScript - 구구단 (0) | 2023.01.24 |
백준 문제풀이[3003] 킹,퀸,룩,비숍,나이트,폰 (0) | 2023.01.22 |