• Skip to primary navigation
  • Skip to content
  • Skip to footer
zhicheng xie's demo blog
  • Quick-Start Guide

    Your Name

    I am an amazing person.

    • Somewhere

    X of a Kind in a Deck of Cards

    less than 1 minute read

    <-E 914> X of a Kind in a Deck of Cards

    class Solution {
    public:
        bool hasGroupsSizeX(vector<int>& deck) {
            unordered_map<int, int> mp;
            for(auto d : deck)
                mp[d]++;
            int x;
            x = mp.begin()->second;
            for(auto it : mp)
                x = gcd(x, it.second);
            if(x > 1) 
                return true;
            return false;
        }
    };
    

    Tags: Algorithms, C++, Leetcode

    Updated: January 3, 2021

    Share on

    Twitter Facebook LinkedIn
    Previous Next

    You may also enjoy

    Decode Ways

    less than 1 minute read

    <-M 91> Decode Ways

    Word Break

    less than 1 minute read

    <-H 139> Word Break

    Distinct Subsequences

    less than 1 minute read

    <-H 115> Distinct Subsequences

    Edit Distance

    less than 1 minute read

    <-H 72> Edit Distance

    • Follow:
    • Feed
    © 2023 zhicheng xie's blog. Powered by Jekyll & Minimal Mistakes.