JAVA || BEGINNERS FRIENDLY||🔥🔥
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 {
    class p{
        char ch;
        int idx;
        p(char ch , int idx){
            this.ch=ch;
            this.idx=idx;
        }
    }
    public String clearStars(String s) {
        char[] word=s.toCharArray();
        PriorityQueue<p>pq=new PriorityQueue<>((a,b)->{
            if(a.ch==b.ch){
                return b.idx-a.idx;
            }
            return Character.compare(a.ch,b.ch);
        });
        for(int i=0;i<s.length();i++){
            if(word[i]!='*'){
              pq.add(new p(word[i],i));
              continue;
            }
            if(!pq.isEmpty()){
                int x=pq.poll().idx;
                word[x]='*';
            }
        }
        StringBuilder sb=new StringBuilder("");
           for(char c:word){
            if(c!='*')
             sb.append(c);
        }
        return sb.toString();

        
    }
}
```
['Java']