Faster than 100% of Python
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\nBeats 100.00%of users with Python3\n\n- Space complexity:\n\nBeats 78.57%of users with Python3\n\n# Code\n```\nclass Solution:\n    def shortestBeautifulSubstring(self, s: str, k: int) -> str:\n        ans = \'\'\n        a = \'\'\n        for i in s:\n            if i == \'1\':\n                k -= 1\n            a += i\n            if k == 0:\n                b = a.strip(\'0\').rstrip(\'0\')\n                if len(ans) == 0 or len(b) < len(ans):\n                    ans = b\n                elif b < ans and len(b) <= len(ans):\n                    ans = b\n                ind = a.index(\'1\')\n                a = a[ind+1::]\n                k += 1\n        return ans\n        \n```
['Python3']