[Python3] brute-force
\n\nclass Solution:\n    def shortestBeautifulSubstring(self, s: str, k: int) -> str:\n        ans = \'\'\n        for i in range(len(s)): \n            cnt = 0
\n```\nclass Solution:\n    def shortestBeautifulSubstring(self, s: str, k: int) -> str:\n        ans = \'\'\n        for i in range(len(s)): \n            cnt = 0 \n            for j in range(i, len(s)): \n                if s[j] == \'1\': cnt += 1\n                if cnt == k: \n                    if ans == \'\' or len(ans) > j-i+1: ans = s[i:j+1]\n                    elif len(ans) == j-i+1: ans = min(ans, s[i:j+1])\n                    break \n        return ans \n```\n\nAlternatively\n```\nclass Solution:\n    def shortestBeautifulSubstring(self, s: str, k: int) -> str:\n        ans = \'\'\n        ii = 0 \n        for i, ch in enumerate(s): \n            if ch == \'1\': k -= 1\n            while k < 0 or ii < i and s[ii] == \'0\': \n                if s[ii] == \'1\': k += 1\n                ii += 1\n            if k == 0 and (ans == \'\' or len(ans) > i-ii+1 or len(ans) == i-ii+1 and ans > s[ii : i+1]): ans = s[ii : i+1]\n        return ans \n```
['Python3']