自己写的。StringBuffer.deleteCharAt
找出字符串中第一个只出现一次的字符
https://www.nowcoder.com/practice/e896d0f82f1246a3aa7b232ce38029d4
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            String str = in.nextLine();
            for (int i = 0; i < str.length();) {
                String temp = str.substring(i, i + 1);
                String temp2 = str.substring(i + 1);
                if (temp2 == null || !temp2.contains(temp)) {
                    System.out.println(temp);
                    return;
                } else {
                    StringBuffer sb = new StringBuffer(str);
                    while (sb.indexOf(temp) != -1) {
                        sb.deleteCharAt(sb.indexOf(temp));
                    }
                    str = sb.toString();
                }
            }
        }
        System.out.println("-1");
    }
}

 查看4道真题和解析
查看4道真题和解析