Sliding Window || Comparator method
```\nclass Solution {\n    public String shortestBeautifulSubstring(String s, int k) {\n        //sliding window\n        int count = 0;\n        int n = s.leng
```\nclass Solution {\n    public String shortestBeautifulSubstring(String s, int k) {\n        //sliding window\n        int count = 0;\n        int n = s.length();\n        int left=0, right=0;\n        StringBuilder sb = new StringBuilder();\n        StringBuilder local = new StringBuilder();\n        while(right < n){\n            char c = s.charAt(right);\n            local.append(c);\n            if(c ==\'1\')\n                count++;\n            while(count == k && left <= right){ \n                if(s.charAt(left) == \'1\'){\n                    if(sb.length()==0 || sb.length()>local.length() || (sb.length()==local.length() && compare(sb, local) > 0)){\n                        sb = new StringBuilder(local);\n                    }\n                }\n                if(s.charAt(left)==\'1\')\n                    count--;\n                local.deleteCharAt(0);\n                left++;\n            }\n            right++;\n        }\n        return sb.toString();\n    }\n    public int compare(StringBuilder sb1, StringBuilder sb2){\n        //assuming same length\n        int i=0;\n        while(i<sb1.length()){\n            int a = sb1.charAt(i); \n            int b = sb2.charAt(i++); \n            if(a==b)\n                continue;\n            else\n                return a-b;\n        }\n        return 0;\n    }\n}
['Array', 'Sliding Window', 'Java']