Python3 Simple Solution | Sliding Window
Steps to follow -:\na) First of all count the number of ones in the array which will represent our window size.\nb) Make a variable to keep count of ones in cur
Steps to follow -:\na) First of all count the number of ones in the array which will represent our window size.\nb) Make a variable to keep count of ones in current window and a variable to keep maximum ones count.\nc) Now, run a loop till twice of the size of array since we have given a circular array.\nd) Check if current element is 1 then increase our current window variable by 1.\ne) Also, keep a check if index is greater than window size and first element of window is 1 then decrease our current window variable by 1\nf) Modify maximum one count variable at the end of each loop with maximum of current window variable and maximum one count variable.\ng) Finally, return the difference of total ones and maximum one count variable.\n\n```\ndef minSwaps(self, nums: List[int]) -> int:\n\t\ttotalOnes = nums.count(1)   #totalOnes is our window size\n        n = len(nums)\n        maxOnesInWindow = 0\n        onesInCurrWindow = 0\n        for i in range(n2):\n            if nums[i%n]:\n                onesInCurrWindow += 1\n            if i >= totalOnes and nums[i%n-totalOnes]:\n                onesInCurrWindow -= 1\n            maxOnesInWindow = max(maxOnesInWindow,onesInCurrWindow)\n        return totalOnes-maxOnesInWindow\n```\n\nPlease upvote if you find it helpful !!\n\t\t\n\t
['Sliding Window', 'Python']