Easy JAVA Solution || 100% faster || 2ms
\n- Time complexity: O(n)\n\n- Space complexity: O(n)\n\n\nclass Solution {\n    public String shortestBeautifulSubstring(String s, int k) {\n\n    List<String>
\n- Time complexity: O(n)\n\n- Space complexity: O(n)\n\n```\nclass Solution {\n    public String shortestBeautifulSubstring(String s, int k) {\n\n    List<String> list=new ArrayList<>();\n    int i=0,j=0;\n    int count=0;\n    int len=Integer.MAX_VALUE;\n    while(j<s.length())\n    {\n        if(count==k)\n        {\n            list.add(s.substring(i,j+1));\n            len=Math.min(len,(j-i+1));\n            if(s.charAt(i)==\'1\'){\n                count--;j++;\n            }\n            i++;\n        }\n        else\n        {\n            if(s.charAt(j)==\'1\'){ count++; if(count==k){j--;} }\n            j++;\n        }\n    }   \n    if(list.size()==0) return "";\n    int idx=-1;\n    for(i=0;i<list.size();i++)\n    {\n        if(len==list.get(i).length())\n        {  \n            if(idx==-1){\n               idx=i;\n            }\n            else if(list.get(idx).compareTo(list.get(i))>0){\n                idx=i;\n            }\n        }\n    }\n    return list.get(idx);\n    }\n}\n```
['Java']