LeetCode——1128. 等价多米诺骨牌对的数量

LeetCode——1128. 等价多米诺骨牌对的数量_第1张图片

 

class Solution:
    def numEquivDominoPairs(self, dominoes: List[List[int]]) -> int:
        if not dominoes:
            return 0
        
        dic = defaultdict(int)
        for x,y in dominoes:
            if x
  • 利用hash表存储出现的次数
  • 然后计算有多少对即可 
  • easy题重拳出击

 

你可能感兴趣的:(Leetcode,数组,leetcode,算法,python,hash)