Basic yet highly efficient solution.
Complexity\n- Time complexity: (O(n)+O(windowSize)+O(n))~O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity:O(1)\n Add your space complexity
# Complexity\n- Time complexity: (O(n)+O(windowSize)+O(n))~O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public int minSwaps(int[] nums) {\n        int windowSize=0;\n        int minimumSwap=0;\n        int currentZero=0;\n        int n=nums.length;\n        for(int num: nums){\n          windowSize+=num;\n        }\n        for(int i=0;i<windowSize;i++){\n            if(nums[i]==0)currentZero++;\n        }\n        int start=0;\n        int end=windowSize-1;\n        minimumSwap=currentZero;\n        while(start<n){\n            if(nums[start]==0){\n                currentZero--;\n            }\n            start++;\n            end++;\n            if(nums[end%n]==0){\n                currentZero++;\n            }\n            minimumSwap=Math.min(minimumSwap,currentZero);\n        }\n        return minimumSwap;\n    }\n} \n
['Array', 'Sliding Window', 'Java']