Python | Leetcode Python题解之第461题汉明距离

题目:

题解:

python 复制代码
class Solution:
    def hammingDistance(self, x, y):
        ret = 0
        bx, by = bin(x)[2:].zfill(32), bin(y)[2:].zfill(32)
        for i in range(32):
            if bx[i] != by[i]:
                ret += 1
        return ret
相关推荐
geovindu9 分钟前
python: Command Pattern
开发语言·python·命令模式
曲幽27 分钟前
FastAPI实战:WebSocket长连接保持与心跳机制,从入门到填坑
javascript·python·websocket·keep-alive·fastapi·heartbeat·connection
锅包一切1 小时前
PART17 一维动态规划
c++·学习·算法·leetcode·动态规划·力扣·刷题
好学且牛逼的马2 小时前
从“混沌初开”到“有序统一”:Java集合框架发展历程与核心知识点详解
前端·数据库·python
a1117762 小时前
快速制作 虚拟形象项目 MotionPNGTuber
python·live2d
一切尽在,你来2 小时前
AI大模型应用开发前置知识:Python迭代器和生成器深入详解
python·langchain·ai编程
小雨中_3 小时前
2.7 强化学习分类
人工智能·python·深度学习·机器学习·分类·数据挖掘
摩拜芯城IC3 小时前
ATSHA204A‑STUCZ CryptoAuthentication 安全认证芯片IC
python·安全
We་ct3 小时前
LeetCode 226. 翻转二叉树:两种解法(递归+迭代)详解
前端·算法·leetcode·链表·typescript
小雨中_3 小时前
2.4 贝尔曼方程与蒙特卡洛方法
人工智能·python·深度学习·机器学习·自然语言处理