Sliding window with comments, Python
First, by appending nums to nums, you can ignore the effect of split case.\nThen, you look at the window whose width is width. Here, width = the number of 1\'s 
First, by appending nums to nums, you can ignore the effect of split case.\nThen, you look at the window whose width is `width`. Here, `width` = the number of 1\'s in the original nums. This is because you have to gather all 1\'s in this window at the end of some swap operations. Therefore, the number of swap operation is the number of 0\'s in this window. \nThe final answer should be the minimum value of this.\n\n```\nclass Solution:\n    def minSwaps(self, nums: List[int]) -> int:\n        width = sum(num == 1 for num in nums) #width of the window\n        nums += nums\n        res = width\n        curr_zeros = sum(num == 0 for num in nums[:width]) #the first window is nums[:width]\n        \n        for i in range(width, len(nums)):\n            curr_zeros -= (nums[i - width] == 0) #remove the leftmost 0 if exists\n            curr_zeros += (nums[i] == 0) #add the rightmost 0 if exists\n            res = min(res, curr_zeros) #update if needed\n        \n        return res\n```
['Sliding Window', 'Python', 'Python3']