代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
@param m int整型
@param n int整型
@return int整型
class Solution: def countBitDiff(self , m: int, n: int) -> int: # write code here
'''
mtwo = bin(m)
ntwo = bin(n)
def xor(x, y):
return '{1:0{0}b}'.format(len(x), int(x, 2) ^ int(y, 2))
res = xor(mtwo,ntwo)
return res.count('1')
'''
'''改进后的使用python函数的代码'''
#虽然感觉用函数有些作弊QAQ
res = bin(m^n)
return res.count('1')