Java simple solution time complexity O(NlogN)
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```java []
   class Pair{
        char c;
        int ind;
       public Pair(char c,int ind){
           this.c=c;
           this.ind=ind;
       }
    }
class Solution {
    public String clearStars(String s) {
         PriorityQueue<Pair>pq=new PriorityQueue<>((a,b)->{
            if(a.c!=b.c){
                return a.c-b.c;
            }
            else{
                return b.ind-a.ind;
            }
        });
        int i=0;
        for(char ch:s.toCharArray()){
            if(ch=='*'){
              if(!pq.isEmpty()){
                  pq.poll();
              }
            }else{
                pq.offer(new Pair(ch,i));
            }
            i++;
        }

        ArrayList<Pair>list=new ArrayList<>();
        while(!pq.isEmpty()){
            list.add(pq.poll());
        }

        Collections.sort(list,(a,b)->a.ind-b.ind);

        StringBuilder sb=new StringBuilder();
        for(Pair num: list){
          sb.append(num.c);
        }
        return sb.toString();
    }
}
```
['Hash Table', 'String', 'Stack', 'Greedy', 'Heap (Priority Queue)', 'Java']