✔ 나의 답 -> 맞음
import java.util.*;
public class Main{
public static String solution(String input){
String output ="";
while(input.length()!=0){
output+=input.charAt(0);
input = input.replace(String.valueOf(input.charAt(0)),"");
}
return output;
}
public static void main(String[] args){
Scanner kb = new Scanner(System.in);
String input = kb.next();
System.out.println(solution(input));
}
}
✔ 강의 답
import java.util.*;
public class Pro6 {
public static String solution(String str) {
String answer="";
for(int i=0;i<str.length();i++) {
if(str.indexOf(str.charAt(i))==i)
answer+=str.charAt(i);
}
return answer;
}
public static void main(String[] args) {
Scanner kb = new Scanner(System.in);
String str = kb.next();
System.out.println(solution(str));
}
}