Sliding Window | Sorting | Easy | O(nlog(n))
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:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    string shortestBeautifulSubstring(string s, int k) {\n        \n        int n=s.size();\n        map<char,int>mp;\n        vector<string>ans;\n        int i=0;\n        int j=0;\n        int mini=INT_MAX;\n        while(j<n){\n            mp[s[j]]++;\n\n            while(mp[\'1\']>=k&&i<=j){\n                if(mp[\'1\']==k){\n                    ans.push_back(s.substr(i,j-i+1));\n                    mini=min(mini,j-i+1);\n                }\n                mp[s[i]]--;\n                if(mp[s[i]]==0)mp.erase(s[i]);\n                i++;\n            }\n\n            j++;\n        }\n\n        if(ans.size()==0)return "";\n        vector<string>ans2;\n        for(auto it:ans){\n            if(it.size()==mini)ans2.push_back(it);\n        }\n        sort(ans2.begin(),ans2.end());\n        return ans2[0];\n    }\n};\n```
['C++']