java solution
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 Solution {
    public String clearStars(String s) {
        StringBuilder sb=new StringBuilder(s);
        PriorityQueue<Pair<Character, Integer>> pq= new PriorityQueue<>(
            (p,q )->{
               int val= Character.compare(p.getKey(), q.getKey());
               if(val==0){
                return Integer.compare(q.getValue() , p.getValue());
               }
               return val;
            }
        );
        for(int i=0;i<sb.length();i++){
            if(s.charAt(i)!='*'){
                pq.offer(new Pair<>(s.charAt(i), i));
            }
            else{
                if(!pq.isEmpty()){
               Pair<Character, Integer> p=pq.poll();
                sb.setCharAt(p.getValue() , '_');
                sb.setCharAt(i , '_');
                }


            }
        }
       
       
       return sb.toString().replaceAll("_", "");
        
    }
}
```
['Java']