C++ || Sliding window || O(n) || Full exaplanation
1)Count the total number of 1s. Let m be that number\n2)Find contiguous region of length m that has the most 1s in it\n3)The number of 0s in this region is the 
1)Count the total number of 1s. Let **m** be that number\n2)Find **contiguous region** of length **m** that has the most 1s in it\n3)The number of **0s** in this region is the minimum required swaps.*Each swap will move one 1 into the region and **one 0** to the remainder.*\n4)Finally we will use modulo operation for handling the case of circular array.\n\nImplementation:\n```\nclass Solution {\npublic:\n    int minSwaps(vector<int>& nums) {\n        int count_1=0;\n        int n=nums.size();\n        \n        if(n==1)return 0;\n        \n        for(int i=0;i<n;i++){\n            if(nums[i]==1)\n                count_1++;\n        }\n        \n        int windowsize=count_1;   // window size for counting maximum  no. of 1s\n        count_1=0;\n        \n         for(int i=0;i<windowsize;i++){\n             if(nums[i]==1)count_1++;\n        }\n        \n        int mx=count_1;           //for storing maximum count of 1s in a window\n        for(int i=windowsize;i<n+windowsize;i++){\n            if(nums[i%n]==1)\n                count_1++;\n            if(nums[(i-windowsize)%n]==1)\n                count_1--;\n            mx=max(count_1,mx);\n        }\n        \n        return windowsize-mx;\n        \n    }\n};\n```\n\n
['Array', 'C', 'Sliding Window']