Majority Element

    [LeetCode] Majority Element

    #include using Intpair = pair; class Solution { public: int majorityElement(vector& nums) { map m; for (const auto& item : nums) m[item]++; vector v(m.begin(), m.end()); sort(v.begin(), v.end(), [&](Intpair& lRef, Intpair& rRef) { return lRef.second < rRef.second; }); return (*(v.end() - 1)).first; } };