EAZY DOggz
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```\n/**\n * @param {string} s\n * @param {number} k\n * @return {string}\n */\nvar shortestBeautifulSubstring = function(word, k) {\n    let L = 0;  \n    let R = 0;   \n    let ones = 0;   \n    const length = word.length;  \n    let res = \'\'  \n\n    while (R < length) {\n        \n        // increase "1"\n        ones += word[R] === \'1\' ? 1 : 0;\n\n        // Shrink the window if exceeds "k"\n        while(ones >k || word[L] === \'0\'){ \n            ones -= word[L] === \'0\' ? 0 : 1 \n            L++ \n        }\n\n        R++;\n\n        // Get the current substring \n        const substring = word.slice(L, R);\n\n        // if one reaches k,\n        // update res \n        if (ones === k){\n\n            // if shorter \n            if (res === \'\' || R - L < res.length){\n                res = substring \n            \n            } \n            // if lexi smaller \n            if (R - L === res.length && substring < res) {\n                res = substring \n        }\n        }\n    }\n\n    return res;\n}\n\n```
['JavaScript']