[Easy]  ||  [C++]  ||  [Sliding Window]
\n# Code\n\nclass Solution {\npublic:\n    string shortestBeautifulSubstring(string s, int k) {\n        int n=s.length();\n        int one = 0;\n        int le
\n# Code\n```\nclass Solution {\npublic:\n    string shortestBeautifulSubstring(string s, int k) {\n        int n=s.length();\n        int one = 0;\n        int len=INT_MAX;\n        int temp=0;\n\n\n        for(int i=0;i<n;i++)\n        {\n            if(s[i]==\'1\')\n            {\n                temp++;\n            }\n        }\n        if(temp<k)\n        {\n            return "";\n        }\n    \n\n        int l=0,r=0;\n        while(r<n)\n        {\n            if(s[r]==\'1\')\n            {\n                one++;\n            }\n            while(one>k || s[l]==\'0\')\n            {\n                if(s[l]==\'1\')\n                {\n                    one--;\n                }\n                l++;\n            }\n            if(one==k)\n            {\n                len=min(len,r-l+1);\n            }\n            r++;\n        }\n\n\n\n        one=0;\n        for(int i=0;i<len;i++)\n        {\n            if(s[i]==\'1\')\n            {\n                one++;\n            }\n        }\n\n\n        l=0;\n        r=len-1;\n        string ans="";\n        for(int k=0;k<len;k++)\n        {\n            ans+=\'1\';\n        }\n\n\n        while(r<n)\n        {\n            if(one==k)\n            {\n                string x = "";\n                for(int i=l;i<=r;i++)\n                {\n                    x+=s[i];\n                }\n                \n                ans=min(x,ans);\n            }\n            if(s[l]==\'1\')\n            {\n                one=one-1;\n            }\n            l++;\n            r++;\n            if(s[r]==\'1\')\n            {\n                one++;\n            } \n        }\n        return ans;\n    }\n};\n```
['C++']