C++ sliding window
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```cpp []\nclass Solution {\npublic:\n    string shortestBeautifulSubstring(string s, int k) {\n        int l = 0, r = 0;\n        int cur = 0;\n        string ans = "";\n        for(int i = 0 ; i < s.size() ; i++){\n            if(s[i] == \'1\') cur++;\n            while(l < i && cur > k){\n                if(s[l] == \'1\') cur--;\n                l++;\n            }\n            while ((l < i) && (s[l] == \'0\')) l++;\n            if(cur == k){\n                if(ans.size() == 0) ans = s.substr(l,i-l+1);\n                else if(i - l + 1 < ans.size()) ans = s.substr(l,i-l+1);\n                else if(i - l + 1 == ans.size()){\n                    string tmp = s.substr(l,i-l+1);\n                    ans = cmp(ans, tmp);\n                }\n            }\n        }\n\n        return ans;\n    }\n    string cmp(string s1, string s2){\n        for(int i = 0 ; i < s1.size() ; i++){\n            if(s1[i] > s2[i]) return s2;\n            else if(s2[i] > s1[i]) break;\n        }\n        return s1;\n    }\n};\n```
['Sliding Window', 'C++']