class Solution { public: int majorityElement(vector<int>& nums) { int m = 0, c = 0; for (auto i : nums) { if (c == 0) { m = i; c++; } else if (i == m) c++; else c--; } return m; } };