思路

1、该问题可以直接利用字符串包含不包含,截取


import java.util.*;

public class Main{
    public static void main(String agrs[]) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String result = "";
        for (int i = line.length(); i > 0; i--) {
            if (!result.contains(line.substring(i-1,i))) {
                result += line.substring(i-1,i);
            }
        }
        System.out.println(result);
        
    }
}