用 set 存储 s2 的每个字符,然后遍历 s1 的每个字符,如果 set 中包含该字符,则跳过,若不包含,则输出
必须用快读和快写!!
import java.io.*;
import java.util.HashSet;
import java.util.Set;
public class Main {
static Set<Character> set = new HashSet<>();
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
String s1 = br.readLine();
String s2 = br.readLine();
for (int i = 0; i < s2.length(); i++) {
set.add(s2.charAt(i));
}
for (int i = 0; i < s1.length(); i++) {
char c = s1.charAt(i);
if (set.contains(c)) {
continue;
} else {
bw.write(c);
}
}
bw.flush();
}
}