EASY AND SIMPLE APPROACH
Complexity\n- Time complexity: O(N)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(1)\n Add your space complexity here, e.g. O(n) \n\n# Co
# Complexity\n- Time complexity: O(N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int minSwaps(vector<int>& v) {\n        int ones = 0;\n        for (auto& x : v) {\n            if (x == 1) {\n                ones++;\n            }\n        }\n        \n        if (ones == 0 || ones == 1) {\n            return 0;\n        }\n        \n        int n = v.size();\n        int windowSum = accumulate(v.begin(), v.begin() + ones, 0);\n        int maxOnesInWindow = windowSum;\n        \n        for (int i = 0; i < n; ++i) {\n            int end = (i + ones) % n; \n            int start = i;\n            \n            windowSum -= v[start];\n            windowSum += v[end];\n            \n            maxOnesInWindow = max(maxOnesInWindow, windowSum);\n        }\n        \n        return ones - maxOnesInWindow;\n    }\n};\n\n```
['Array', 'Sliding Window', 'C++']