C++ sliding window
\nclass Solution {\npublic:\n    int minSwaps(vector<int>& nums) {\n        int n = nums.size(), res = INT_MAX;\n        int ones = count(nums.begin(), nums.end
```\nclass Solution {\npublic:\n    int minSwaps(vector<int>& nums) {\n        int n = nums.size(), res = INT_MAX;\n        int ones = count(nums.begin(), nums.end(), 1);\n        int zcnt = 0;\n        if (!ones)\n            return 0;\n        for (int l = 0, r = 0; l < n; r = (r + 1) % n) {\n            zcnt += !nums[r];\n            if (r - l + 1 == ones || r < l) {\n                res = min(res, zcnt);\n                zcnt -= !nums[l++];\n            }\n        }\n        return res;\n    }\n};\n```
[]