Typical Sliding Window || Easy Solution || WIth comments || Beginner Friendly ||
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<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\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        \n        string ans;\n        int n=s.length();\n        int left=0;\n        int right=0;\n\n        int cnt1=0;\n\n        while(right<n){\n            if(s[right]==\'1\'){\n                cnt1++;\n            }\n\n            if(cnt1==k){  // shrink the window\n                while(left<n && cnt1==k){   \n\n                    string temp= s.substr(left,right-left+1); // substr : {index,size}\n\n                    if(ans.size()==0 || temp.size()<ans.size()) {  // shortest length check\n                        ans=temp;\n                    }\n                    else if(temp.size()==ans.size()){   // lexicographically smallest check\n                        ans=min(ans,temp);\n                    }\n\n                    if(s[left]==\'1\'){\n                        cnt1--;\n                    }\n                    left++;\n                }\n            }\n            right++;\n        }\n        return ans;\n    }\n};\n```
['C++']