✅Accepted Java Code || Beats 100%
Complexity\n- Time complexity : O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity : O(n)\n Add your space complexity here, e.g. O(n) \n\n# 
# Complexity\n- Time complexity : $$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity : $$O(n)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```JAVA []\nclass Solution {\n    int N = 0;\n    int nextOne(String s, int i){\n        for(i++; i < N;i++)\n            if(s.charAt(i) == \'1\')\n                return i;\n        return -1;\n    }\n    public String shortestBeautifulSubstring(String s, int k) {\n        N = s.length();\n        int i = nextOne(s, -1);\n        int j = i, c = 1;\n        while(c != k && j != -1){\n            j = nextOne(s, j);\n            c++;\n        }\n        if(c != k || j == -1) return "";\n        int min = j - i + 1, minIndex = i;\n        String r = s.substring(i, i + min);\n        i = nextOne(s, i); j = nextOne(s, j);\n        while(j != -1){\n            int temp = j - i + 1;\n            if(temp < min){\n                min = j - i + 1;\n                minIndex = i;\n                r = s.substring(i ,i + min);\n            }\n            else if(temp == min){\n                String r1 = s.substring(i, i + min);\n                if(r1.compareTo(r) < 0){\n                    minIndex = i;\n                    r = r1;\n                }\n            }\n            i = nextOne(s, i);\n            j = nextOne(s, j);\n\n        }\n        return r;\n    }\n}\n```\n>>> ## Upvote\uD83D\uDC4D if you find helpful\n
['String', 'String Matching', 'Java']