Sliding Window Solution
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        int i = 0, j = 0, cnt = 0, n = s.size();\n        string ans = "";\n        while (j < n) {\n            if (s[j] == \'1\')\n                cnt++;\n            while (cnt == k) {\n                string temp = s.substr(i, j - i + 1);\n                if (ans.size() == 0 || temp.size() < ans.size()) {\n                    ans = temp;\n                } else if (temp.size() == ans.size()) {\n                    ans = min(ans, temp);\n                }\n                if (s[i] == \'1\')\n                    cnt--;\n                i++;\n            }\n            j++;\n        }\n        return ans;\n    }\n};\n```
['C++']