Short and crisp CPP solution
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \nKeep 2 pointers, keep o
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nKeep 2 pointers, keep on expanding the window until you hit cnt == k, then shrink it and check for all the cases. Pretty straightforward.\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        int left = 0,right=0,cnt=0;\n        string temp = "",res = "";\n          \n        while(right < s.size()){\n          if(s[right] == \'1\') cnt++;\n\n          while(cnt == k){\n            temp = s.substr(left,right-left+1);\n            if(res == "") res = temp;\n            else if(res.length() > temp.length()) res = temp;\n            else if(res.length() == temp.length() and res > temp)\n                res = temp;\n\n              if(s[left] == \'1\') cnt--;\n              left++;\n                 \n          }\n\n          right++;\n        }\n\n        return res;\n    }\n};\n```
['C++']