题解 | #字符集合#
字符集合
https://www.nowcoder.com/practice/784efd40ed8e465a84821c8f3970b7b5
import java.util.Scanner; public class Main { public static String func(String s) { int ret = 0; char[] arr = new char[128]; StringBuilder str = new StringBuilder(); for (int i = 0; i < s.length(); i++) { if (arr[s.charAt(i)] == 0) { str.append(s.charAt(i)); arr[s.charAt(i)]++; } } return str.toString(); } public static void main(String[] args) { Scanner in = new Scanner(System.in); while (in.hasNextLine()) { System.out.println(func(in.nextLine())); } } }