题解 | #提取不重复的整数#
提取不重复的整数
http://www.nowcoder.com/practice/253986e66d114d378ae8de2e6c4577c1
input(int) -> 字符串数组 -> 逆序添加到新的字符串out -> output(int)
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int input = sc.nextInt();
int output = new Solution().update(input);
System.out.println(output);
}
}
class Solution {
public int update(int num) {
String string = num + "";
String[] str = string.split("");
String out = "";
for (int i = str.length - 1; i >= 0; i--) {
if (!out.contains(str[i])) {
out = out + str[i];
}
}
int result = Integer.parseInt(out);
return result;
}
}