Minimize Length of Array Using Operations⚓︎ Link Solution⚓︎ See reference (Chinese) and std::count. 1 2 3 4 5 6 7 8 9 10class Solution { public: int minimumArrayLength(vector<int>& nums) { int m = *min_element(nums.begin(), nums.end()); for (int num : nums) { if (num % m) return 1; } return (count(nums.begin(), nums.end(), m) + 1) / 2; } }; Time complexity: \(O(n)\); Space complexity: \(O(1)\).