category-wise-problems

contains category wise problems(data structures, competitive) of popular platforms.

View the Project on GitHub mayankdutta/category-wise-problems

2134. Minimum Swaps to Group All 1’s Together II

code implementation ```cpp class Solution { public: int minSwaps(vector& nums) { vector arr(nums); int n = arr.size(); int k = count(arr.begin(), arr.end(), 1); int count = 0; for (int i = 0; i < k; i++) count += (arr[i] == 0); int ans = count; for (int i = k; i < n + k; i++) { count -= (arr[i - k] == 0); count += (arr[i % n] == 0); ans = min(ans, count); } return ans; } }; ``` </details>