C++ || Easy Video Solution || Faster than 97%
The video soltuion for the below code is\nhttps://youtu.be/ow8SNSXYepc\n\n# Code\n\nclass Solution {\nprivate:\n    int minCount(vector<int>& nums, int check){\
The video soltuion for the below code is\nhttps://youtu.be/ow8SNSXYepc\n\n# Code\n```\nclass Solution {\nprivate:\n    int minCount(vector<int>& nums, int check){\n        int sz = nums.size();\n        int windowSize = 0;\n        for(auto &num : nums) windowSize += (num == check);\n        int maxWindowCheckerCnt = INT_MIN; // Will have max size of checker numbers that are present in any window\n        int currWindowCheckerCnt = 0;\n        for(int i = 0 ; i < windowSize ; i++){\n            currWindowCheckerCnt += (nums[i] == check);\n        }\n        maxWindowCheckerCnt = max(maxWindowCheckerCnt, currWindowCheckerCnt);\n        for(int i = windowSize ; i < sz ; i++){\n            currWindowCheckerCnt -= (nums[i - windowSize] == check);\n            currWindowCheckerCnt += (nums[i] == check);\n            maxWindowCheckerCnt = max(maxWindowCheckerCnt, currWindowCheckerCnt);\n        }\n        return windowSize - maxWindowCheckerCnt;\n    }\npublic:\n    int minSwaps(vector<int>& nums) {\n        ios_base::sync_with_stdio(false);\n        cin.tie(NULL);\n        cout.tie(NULL);\n        // 0 1 0 1 1 0 0\n        // 0 0 1 1 1 0 0 -- 1st Way\n        // 0 0 0 1 1 1 0 -- 2nd Way\n\n        // 1 1 0 0 1 -- Linear array -- 1\n        \n\n        // Linear array\n        // 1 0 0 0 0 1 0 1 1 0 1\n        // All 5 ones should be grouped together\n        // 1st window --> 1, 1 0 0 0 0\n        // 2nd window --> 1, 0 0 0 0 1\n        // 3rd window --> 1, 0 0 0 1 0\n        // 4th window --> 2, 0 0 1 0 1 --> 3 ops\n        // 5th window --> 3, 0 1 0 1 1\n        // 6th window --> 3, 1 0 1 1 0 --> 2 ops\n        // 7th window --> 3, 0 1 1 0 1 --> 2 ops\n\n        // Intuition --> Linear --> Count number of ones present in the linear vector for all the windows with size total number of ones we will find the window which is having maximum number of ones and subract it with original window size.\n\n\n        // Circular array\n        // Instead of ones I will group all 0\'s\n        // 0 1 1 1 1 0 1 0 0 1 0\n        // 2 ops\n        // <1>\'s<0\'s><1\'s>\n        return min(minCount(nums, 1), minCount(nums, 0));\n    }\n};\n```
['C++']