世界上有10种人,一种懂二进制,一种不懂。那么你知道两个int32整数m和n的二进制表达,有多少个位(bit)不同么?
示例1
输入
3,5
输出
2
说明
3的二进制为11,5的二进制为101,总共有2位不同
示例2
输入
1999,2299
输出
7
加载中...
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param m int整型 * @param n int整型 * @return int整型 */ public int countBitDiff (int m, int n) { // write code here } }
class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param m int整型 * @param n int整型 * @return int整型 */ int countBitDiff(int m, int n) { // write code here } };
#coding:utf-8 # # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param m int整型 # @param n int整型 # @return int整型 # class Solution: def countBitDiff(self , m , n ): # write code here
using System; using System.Collections.Generic; class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param m int整型 * @param n int整型 * @return int整型 */ public int countBitDiff (int m, int n) { // write code here } }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param m int整型 * @param n int整型 * @return int整型 */ function countBitDiff( m , n ) { // write code here } module.exports = { countBitDiff : countBitDiff };
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param m int整型 # @param n int整型 # @return int整型 # class Solution: def countBitDiff(self , m: int, n: int) -> int: # write code here
package main import "fmt" /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param m int整型 * @param n int整型 * @return int整型 */ func countBitDiff( m int , n int ) int { // write code here }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param m int整型 * @param n int整型 * @return int整型 */ int countBitDiff(int m, int n ) { // write code here }
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param m int整型 # @param n int整型 # @return int整型 # class Solution def countBitDiff(m, n) # write code here end end
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param m int整型 * @param n int整型 * @return int整型 */ def countBitDiff(m: Int,n: Int): Int = { // write code here } }
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param m int整型 * @param n int整型 * @return int整型 */ fun countBitDiff(m: Int,n: Int): Int { // write code here } }
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param m int整型 * @param n int整型 * @return int整型 */ public int countBitDiff (int m, int n) { // write code here } }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param m int整型 * @param n int整型 * @return int整型 */ export function countBitDiff(m: number, n: number): number { // write code here }
public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param m int整型 * @param n int整型 * @return int整型 */ func countBitDiff ( _ m: Int, _ n: Int) -> Int { // write code here } }
struct Solution{ } impl Solution { fn new() -> Self { Solution{} } /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param m int整型 * @param n int整型 * @return int整型 */ pub fn countBitDiff(&self, m: i32, n: i32) -> i32 { // write code here } }
3,5
2
1999,2299
7