leetcode 461. Hamming Distance
来源:互联网 发布:竞彩足球奖金优化 编辑:程序博客网 时间:2024/05/22 11:49
The Hamming distance between two integers is the number of positions at which the corresponding bits are different.
Given two integers x and y, calculate the Hamming distance.
class Solution(object): def hammingDistance(self, x, y): """ :type x: int :type y: int :rtype: int """ return bin(x^y).count('1')
bin函数:将int转换成二进制bit的字符串,前面会有’0b’
bin(5)=’0b101’
0 0
- LeetCode 461. Hamming Distance
- 【Leetcode】461. Hamming Distance
- LeetCode 461. Hamming Distance
- LeetCode - 461. Hamming Distance
- LeetCode-461. Hamming Distance
- 【LeetCode】 461. Hamming Distance
- Leetcode-461. Hamming Distance
- Leetcode 461. Hamming Distance
- LeetCode--461. Hamming Distance
- 461. Hamming Distance [LeetCode]
- [LeetCode]461. Hamming Distance
- leetcode 461. Hamming Distance
- Leetcode 461. Hamming Distance
- LeetCode 461. Hamming Distance
- 【LeetCode】461. Hamming Distance
- LeetCode-461. Hamming Distance
- LeetCode | 461. Hamming Distance
- [LeetCode]461.Hamming Distance
- codeforces 547C. Mike and Foam (反演)
- hadoop运行过程中报错:ERROR lzo.LzoCodec: Cannot load native-lzo without native-hadoop
- 2017年3月21日kettle步骤概览--抽取
- iOS中的两种主要架构及其优缺点
- 可用的Qt设置桌面图标方法
- leetcode 461. Hamming Distance
- Android动态加载补充 加载SD卡中的SO库
- C# 服务端推送,十步十分钟,从注册到推送成功
- Timer和spring的Quartz两种定时器的区别。
- 中小型企业管理软件功能特点有哪些?
- 476. Number Complement
- GreenVPN使用
- 论快速原型设计的重要性
- NDK学习笔记<二> 使用javah生成头文件