Sliding Window Intution | 
Intuitionafter reading problem we will get a ques in our mind that what is the exact position in whole nums, where we can put all ones together, is it in middle
# Intuition
after reading problem we will get a ques in our mind that what is the exact position in whole nums, where we can put all ones together, is it in middle or in leftmost or rightmost position ? but ques is asking to only make them together, so at the end, we will have all ones together so, can we check in whole array what is that position where all ones are together ? yes using sliding window of size  = count of ones, we can check for a particular window that how much swaps this particular window require, and min swaps will be our ans and to eliminate circular propert of array we can append orignal array to itself

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class Solution {
public:
    int minSwaps(vector<int>& nums) {
        // after reading problem we will get a ques that what is the exact position in whole nums, where we can put all ones together, is it in middle or in leftmost or rightmost position ? but ques is asking to only make them together, so at the end, we will have all ones together so, can we check in whole array what is that position where all ones are together ? yes using sliding window of size  = count of ones, we can check for a particular window that how much swaps this particular window require, and min swaps will be our ans and to eliminate circular propert of array we can append orignal array to itself
        int n = nums.size(), i = 0, j = 0, cntOne = 0;
        for (auto& it : nums)
            if (it == 1)
                cntOne++;
        int k = cntOne, sum = 0, res = k;
        nums.insert(nums.end(), nums.begin(), nums.end());
        while (j < 2 * n) {
            sum += nums[j];
            if ((j - i + 1) > k) {
                sum -= nums[i];
                i++;
            }
            if ((j - i + 1) == k)
                res = min(res, k - sum);
            j++;
        }
        return res;
    }
};
```
['C++']