Simple Python Code
IntuitionTwo pointer & sliding window.Approachhave two pointer assigned to 0, create a occurance dictionary to store occurance of numbers, if any numbers occura
# Intuition
Two pointer & sliding window.

# Approach
have two pointer assigned to 0, create a occurance dictionary to store occurance of numbers, if any numbers occurance == k, increment the left point till the numbers occurance < k. the calculate the max Length.

# Complexity
- Time complexity:
O(N)

- Space complexity:
O(N)

![image.png](https://assets.leetcode.com/users/images/69ef6a50-94e2-463e-9cf4-00230f69fd91_1735222557.4933686.png)

# Code
```python3 []
class Solution:
    def shortestBeautifulSubstring(self, s: str, k: int) -> str:
        l,r = 0,0
        occ = defaultdict(int)
        _len = len(s)
        res = ""
        maxLen = 10**9
        while r < _len:
            if s[r] == "1":
                occ[s[r]] += 1
            while occ[s[r]] == k:
                if r-l <= maxLen:
                    if maxLen == r-l:
                        if int(res) > int(s[l:r+1]):
                            res = s[l:r+1]
                    else:
                        res = s[l:r+1]
                    maxLen = r-l
                if s[l] in occ and s[l] == "1":
                    occ[s[l]] -= 1
                l += 1
            r += 1
        return res
            
```
['Sliding Window', 'Python3']