Debug --> python统计列表中元素个数

1. 建一个hashmap

hashmap[list[i]] = list.count(list[i])

 

2. Counter 类!  大规模数据集超级好用,且快。

食用方法如下!

 

 

 

 

计算汉明距离:两数二进制异或后结果中'1'的个数

class Solution:
    def hammingDistance(self, x: int, y: int) -> int:
        return bin(x^y).count('1')

 

posted @ 2022-01-23 13:24  阿洛萌萌哒  阅读(149)  评论(0编辑  收藏  举报