My Solution
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
![image.png](https://assets.leetcode.com/users/images/8df8cd64-46a1-47c7-a654-dd721fbf9ea5_1743728992.8674438.png)

# 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
```cpp []
class Solution {
public:
    string clearStars(string s) 
    {
        vector<vector<int>> indices(26);

        for(int i = 0; i < s.size(); i++)
        {
            int index = s[i] - 'a';
            if(s[i] == '*')
            {
                for(int j = 0; j < indices.size(); j++)
                {
                    if(!indices[j].empty())
                    {
                        indices[j].pop_back();
                        break;
                    }
                }
            }
            else
            {
                indices[index].push_back(i);
            }
        }


        vector<char> new_string(s.size());

        for(int i = 0; i < indices.size(); i++)
        {
            if(!indices[i].empty())
            {
                for(int j = 0; j < indices[i].size(); j++)
                {
                    int index = indices[i][j];
                    new_string[index] = i + 'a';
                }
            }
        }

        string ans;
        for(int i = 0; i < new_string.size(); i++)
        {
            if(isalpha(new_string[i]))
            {
                ans += new_string[i];
            }
        }

        return ans;
    }
};
```
['C++']