little bit hard question solved using hashtable  and hashset
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\no(n)\n\n- Space complexity:\no(n)\n\n# Code\n```java []\nclass Solution {\n    public String clearStars(String s) {\n        HashMap<Character,LinkedList<Integer>> map=new HashMap<>();\n        HashSet<Integer> remIndex=new HashSet<>();\n        int min=Integer.MAX_VALUE;\n        for(int i=0;i<s.length();i++){\n            char ch=s.charAt(i);\n            if(ch==\'*\'){\n                if(!map.isEmpty()){\n                char smallest=Collections.min(map.keySet());\n                int remLast=map.get(smallest).removeLast();\n                remIndex.add(remLast);\n                if(map.get(smallest).isEmpty()){\n                    map.remove(smallest);\n                }\n                continue;\n            }\n            \n            \n\n        }\n        map.putIfAbsent(ch,new LinkedList<>());\n            map.get(ch).add(i);\n        }\n        StringBuilder result=new StringBuilder();\n        for(int i=0;i<s.length();i++){\n            char ch=s.charAt(i);\n            if(ch!=\'*\'&&!remIndex.contains(i)){\n                result.append(ch);\n            }\n           \n               \n                \n            }\n            \n            \n\n\n        \n        \n    \n        return result.toString();\n    }\n}\n\n```
['Java']