Java | Sliding Window | Easy to understand | 👍🏻
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        \n        int n = s.length();\n\n        int start = 0;\n        int end = 0;\n\n        int countOne = 0;\n\n        String smallestLexiStr = "";\n\n        while(end < n){\n\n            countOne += (s.charAt(end) - \'0\');\n\n            while(end > start && (countOne > k || s.charAt(start) == \'0\')){\n                countOne -= (s.charAt(start) - \'0\');\n                start++;\n            }\n\n            if(countOne == k){\n                int len = (end - start + 1);\n                String substr = s.substring(start, start + len);\n                smallestLexiStr = "".equals(smallestLexiStr)\n                                || len < smallestLexiStr.length()\n                                || (len == smallestLexiStr.length() && substr.compareTo(smallestLexiStr) <= 0)\n                    ? substr : smallestLexiStr;\n            }\n\n            end++;\n        }\n        return smallestLexiStr;\n    }\n}\n```
['Two Pointers', 'String', 'Sliding Window', 'Java']