Simple Sliding window approach
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# 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 shortestBeautifulSubstring(string s, int k) {
        int start = -1, end = -1, n = s.size(), cnt = 0, i = 0;
        vector<string> res;

        for (int j = 0; j < n; j++) {
            cnt += s[j] == '1' ? 1 : 0;

            while (cnt == k) {
                if (start == -1 || end - start >= j - i) {
                    start = i, end = j;
                }
                cnt -= s[i] == '1' ? 1 : 0;
                i++;
            }

            if (start != -1) {
                if (res.size() == 0 || res[0].size() == end - start + 1) {
                    res.push_back(s.substr(start, end - start + 1));
                } else if (res[0].size() > end - start + 1) {
                    res.clear();
                    res.push_back(s.substr(start, end - start + 1));
                }
            }
        }
        if (res.size() == 0)
            return "";

        sort(res.begin(), res.end());
        return res[0];
    }
};
```
['C++']