题解 | #提取不重复的整数#
提取不重复的整数
http://www.nowcoder.com/practice/253986e66d114d378ae8de2e6c4577c1
import java.util.*; //从末尾遍历,去重放进list public class Main{ public static void main(String[] args){ Scanner scanner = new Scanner(System.in); int indata = scanner.nextInt(); String indataStr = indata + ""; List<Character> outdataList = new ArrayList<Character>(); for(int i = indataStr.length()-1; i>=0 ;i--){ //查找相同的字符 if(!outdataList.contains(indataStr.charAt(i))){ outdataList.add(indataStr.charAt(i)); } } //遍历list for(Character num : outdataList){ System.out.print(Integer.parseInt(num + "")); } } }