Java | Sliding Window | Using Queue
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```\nimport java.util.LinkedList;\nimport java.util.Queue;\n\nclass Solution {\n    public String shortestBeautifulSubstring(String s, int k) {\n        Queue<Integer> queue = new LinkedList<>();\n        int minLen = Integer.MAX_VALUE;\n        String minStr = "";\n\n        for (int i = 0; i < s.length(); i++) {\n            if (s.charAt(i) == \'1\') {\n                queue.add(i);\n                if (queue.size() == k) {\n                    int start = queue.peek();\n                    int len = i - start + 1;\n                    String str = s.substring(start, i + 1);\n                    if (len < minLen || (len == minLen && str.compareTo(minStr) < 0)) {\n                        minLen = len;\n                        minStr = str;\n                    }\n                    queue.poll();\n                }\n            }\n        }\n\n        return minStr;\n    }\n}\n\n```
['Java']