【Leetcode_easy】1128. Number of Equivalent Domino Pairs

problem

1128. Number of Equivalent Domino Pairs

solution1:

不明白为什么每个元素都要加上count;

class Solution {
public:
    int numEquivDominoPairs(vector<vector<int>>& dominoes) {
        int res = 0;
        unordered_map<int, int> count;
        for(auto d:dominoes)
        {
            res += count[min(d[0], d[1])*10+max(d[0], d[1])]++;
        }
        return res;
    }
};

参考

1. Leetcode_easy_1128. Number of Equivalent Domino Pairs;

2. Discuss;

posted on 2019-07-23 17:50  鹅要长大  阅读(142)  评论(0编辑  收藏  举报

导航