JAVA | O(N) ~ O(N * log(26))| Beats 100% java users | Simple TreeMap Solution
\npublic static String clearStars(String s) {\n        TreeMap<Integer, Stack<Integer>> tm = new TreeMap<>();\n        int[]del = new int[s.length()];\n        
```\npublic static String clearStars(String s) {\n        TreeMap<Integer, Stack<Integer>> tm = new TreeMap<>();\n        int[]del = new int[s.length()];\n        for(int i = 0; i<s.length(); i++){\n            if(s.charAt(i) != \'*\'){\n                tm.putIfAbsent(s.charAt(i) + \'0\', new Stack<>());\n                tm.get(s.charAt(i) + \'0\').add(i);\n                continue;\n            }\n            del[i] = 1;\n            Integer smallestChar = tm.ceilingKey(\'a\' + \'0\');\n            if(smallestChar==null)continue;\n            Stack<Integer> st = tm.get(smallestChar);\n            del[st.pop()] = 1;\n            if(st.isEmpty()){\n                tm.remove(smallestChar);\n            }    \n            \n        }\n        StringBuilder result = new StringBuilder();\n        for(int  i = 0; i<del.length; i++){\n            if(del[i] == 1)continue;\n            result.append(s.charAt(i));\n        }        \n        return result.toString();\n    }\n```
['Tree', 'Binary Tree']