JavaScript Solution - Sliding Window
\nvar minSwaps = function(nums) {\n    const MAX = Number.MAX_SAFE_INTEGER;\n    \n    let ones = nums.reduce((acc, bit) => acc + bit, 0);\n    \n    const doub
```\nvar minSwaps = function(nums) {\n    const MAX = Number.MAX_SAFE_INTEGER;\n    \n    let ones = nums.reduce((acc, bit) => acc + bit, 0);\n    \n    const doubledNums = nums.concat(nums.slice(0, nums.length - 1));\n    \n    let minSwap = MAX;\n    let left = 0;\n    let onesWithinWindow = 0;\n    \n    for (let i = 0; i < doubledNums.length; ++i) {\n        const rightBit = doubledNums[i];\n        \n        if (rightBit === 1) onesWithinWindow += 1;\n        \n        if (i >= ones) {\n            const leftBit = doubledNums[left];\n            \n            if (leftBit === 1) onesWithinWindow -= 1;\n            ++left;\n        }\n       \n        if (i + 1 >= ones) minSwap = Math.min(minSwap, ones - onesWithinWindow);\n    }\n    \n    return minSwap;\n};\n```
['Sliding Window', 'JavaScript']