Simple Java Solution | 1ms | Beats 100%
\n\n# Code\n\nclass Solution {\n    public String shortestBeautifulSubstring(String s, int k) {\n        int i=0,j=0;\n        int n=s.length(),min=Integer.MAX_
\n\n# Code\n```\nclass Solution {\n    public String shortestBeautifulSubstring(String s, int k) {\n        int i=0,j=0;\n        int n=s.length(),min=Integer.MAX_VALUE;\n        String mins=new String(s);\n        while(i<n && s.charAt(i)==\'0\') i++;\n        if(i==n) return "";\n        j=i;\n        while(j<n){\n            if(s.charAt(j)==\'1\') k--;\n            if(k==0){\n                if(j-i+1<min){\n                    min=j-i+1;\n                    mins=new String(s.substring(i,j+1));\n                }\n                else if(j-i+1==min){\n                    String str=s.substring(i,j+1);\n                    if(str.compareTo(mins)<0) mins=new String(str);\n                }\n                i++;\n                k++;\n                while(i<j && s.charAt(i)==\'0\') i++;\n            }\n            j++;\n        }\n        if(min==Integer.MAX_VALUE) return "";\n        return mins;\n    }\n}\n```
['Two Pointers', 'String', 'Sliding Window', 'Java']