Python sliding window O(n)
\nclass Solution:\n    def minSwaps(self, nums: List[int]) -> int:\n        ones = nums.count(1)\n        n = len(nums)\n        res = ones\n        start = 0\n
```\nclass Solution:\n    def minSwaps(self, nums: List[int]) -> int:\n        ones = nums.count(1)\n        n = len(nums)\n        res = ones\n        start = 0\n        end = ones-1\n        zeroesInWindow = sum(num==0 for num in nums[start:end+1])\n        \n        while start < n:\n            # print(start, end , zeroesInWindow)\n            res = min(res, zeroesInWindow)\n            if nums[start] == 0: zeroesInWindow -= 1 \n            start += 1\n            end += 1\n            if nums[end%n] == 0: zeroesInWindow += 1\n                \n        return res\n```
['Sliding Window', 'Python', 'Python3']