package wordcount.消除重复数字以后的最大整数;
import java.util.*;
public class Main {
public static void main(String[] args){
String str="423234";
Node head=new Node();
Node tail=new Node();
head.next=tail;
tail.pre=head;
LinkedList<Integer> list=new LinkedList<>();
Map<Integer,Node> last=new HashMap<>();
for(int i=0;i<str.length();++i){
Integer now=Integer.valueOf( str.substring(i,i+1));
if(last.containsKey(now)){
Node index=last.get(now);
if(index.next!=tail&&index.num<index.next.num){
index.pre.next=index.next;
index.next.pre=index.pre;
Node nowNode= new Node(now);
tail.pre.next=nowNode;
nowNode.pre=tail.pre;
nowNode.next=tail;
tail.pre=nowNode;
last.put(now,nowNode);
}
}else{
Node nowNode= new Node(now);
tail.pre.next=nowNode;
nowNode.pre=tail.pre;
nowNode.next=tail;
tail.pre=nowNode;
last.put(now,nowNode);
}
}
Node curr=head.next;
for(;curr!=tail;curr=curr.next){
System.out.print(curr.num);
}
}
}
class Node{
int num;
Node next;
Node pre;
public Node(){
}
public Node(int num){
this.num=num;
}
}