import java.util.*;
public class NoRepeatInteger {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
String str = s.nextLine();
str= str.trim();
String result = NoRepeat(str);
System.out.println(result);
}
public static String NoRepeat(String str){
if(str==null||str.trim().length()<0) return str;
StringBuilder sb = new StringBuilder();
sb.append(str);
sb.reverse();
String str2 = sb.toString();
char[] c = str2.toCharArray();
int len = c.length;
ArrayList<Character> list = new ArrayList<Character>();
for(int i=0;i<len;i++){
if(!list.contains(c[i])){
list.add(c[i]);
}
}
StringBuilder sb2 = new StringBuilder();
if(list.size()>1){
if(list.get(0)=='0'){
for(int i=1;i<list.size();i++){
sb2.append(list.get(i));
}
}else{
for(int i=0;i<list.size();i++){
sb2.append(list.get(i));
}
}
}else{
if(list.get(0)=='0'){
sb2.append("0");
}else{
sb2.append(list.get(0));
}
}
return sb2.toString();
}
}
NoRepeatInteger
最新推荐文章于 2015-08-17 23:43:35 发布