100% | JAVA
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 {\n    public String shortestBeautifulSubstring(String s, int k) {\n        int k1 = 0;\n        int i = 0;\n        while(i<s.length() && k1<k){\n            if(s.charAt(i) == \'1\') k1++;\n            i++;\n        }\n        if(i == s.length() && k1!=k) return "";\n\n        int j = 0;\n        String ans = s.substring(j,i);\n        while(i<=s.length()) {\n            if(k1 == k) {\n                String key = s.substring(j,i);\n                if(ans.length() > (i-j) || (ans.length() == (i-j) && ans.compareTo(key) > 0) ) {\n                    ans = key;\n                }\n                if(s.charAt(j) == \'1\') {\n                    k1--;\n                }\n                j++;\n            }\n            else{\n                if(i<s.length()) {\n                    if(s.charAt(i) == \'1\') k1++;\n                }\n                i++;\n            }\n        }\n        return ans;\n    }\n}\n```
['Java']