Java - Max Heap Solution
\nclass Solution {\n    public String clearStars(String s) {\n        PriorityQueue<int[]> pq = new PriorityQueue<int[]>((a, b) -> {\n            if (a[0] == b[
```\nclass Solution {\n    public String clearStars(String s) {\n        PriorityQueue<int[]> pq = new PriorityQueue<int[]>((a, b) -> {\n            if (a[0] == b[0]) {\n                return b[1] - a[1];\n            }\n            \n            return a[0] - b[0];\n        });\n        char items[] = s.toCharArray();\n        \n        for (int i = 0; i < s.length(); i++) {\n            if (s.charAt(i) == \'*\') {\n                int item[] = pq.poll();\n                \n                items[item[1]] = \'A\';\n                \n            } else {\n                pq.offer(new int[] {s.charAt(i), i});\n            }\n        }\n        \n        StringBuilder sb = new StringBuilder("");\n        \n        for (int i = 0; i < items.length; i++) {\n            if (items[i] != \'A\' && items[i] != \'*\') {\n                sb.append(items[i]);\n            }\n        }\n        \n        return sb.toString();\n    }\n}\n```
['Java']