【leetcode】1399. 统计最大组的数目

int countLargestGroup(int n){
    int hash[37]={0};
    int map[10001]={0};
    int i, sum, tmp, max=0, cnt=0;
    for(i=1; i<=n; i++){
        map[i]=map[i/10]+i%10;
        hash[map[i]]++;
        if (hash[map[i]]>max)
            max=hash[map[i]];
    }
    for (i=1; i<=36; i++)
        if(hash[i] == max)
            cnt++;
    return cnt;
}
原文地址:https://www.cnblogs.com/ganxiang/p/14041667.html