Easy C++ Solution || Sliding Window
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int minSwaps(vector<int>& nums) {\n        int ans=INT_MAX,cnt0=0,cnt1=0,n=nums.size();\n        for(auto it:nums){\n            if(it==1)\n                cnt1++;\n        }\n        for(int i=0;i<cnt1;i++){\n            if(nums[i]==0)\n                cnt0++;\n        }\n        ans=min(cnt0,ans);\n        for(int i=cnt1;i<2*n;i++){\n            if(nums[i%n]==0)\n                cnt0++;\n            if(nums[(i-cnt1)%n]==0)\n                cnt0--;\n            ans=min(ans,cnt0);\n        }\n        return ans;\n    }\n};\n```
['C++']