simple solution || 6ms || two pointers approach
\n\n# Complexity\n- Time complexity:\n- O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity:\n- O(1)\n Add your space complexity here, e.g. O
\n\n# Complexity\n- Time complexity:\n- O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n- O(1)\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        string ans="";\n        int n=s.size();\n        int i=0,j=0;\n        int len=INT_MAX;\n        int cnt=0;\n        while(j<n){\n           if(s[j]==\'1\'){\n             cnt++;\n           }\n           while(cnt>=k){\n              int currlen = j-i+1;\n              if(len>currlen or(currlen == len and s.substr(i,currlen)<ans)){\n                 len = currlen;\n                 ans = s.substr(i,currlen);\n              }\n              if(s[i]==\'1\'){\n                cnt--;\n              }\n              i++;\n           }\n           j++;\n        }\n        \n        \n        return ans;\n    }\n};\n```
['C++']