leetcode477
public class Solution {
public int TotalHammingDistance(int[] nums) {
int total = , n = nums.Length;
for (int j = ; j < ; j++)
{
int bitCount = ;
for (int i = ; i < n; i++)
{
bitCount += (nums[i] >> j) & ;
}
total += bitCount * (n - bitCount);
}
return total;
}
}
https://leetcode.com/problems/total-hamming-distance/#/description
leetcode477的更多相关文章
- [Swift]LeetCode477. 汉明距离总和 | Total Hamming Distance
The Hamming distance between two integers is the number of positions at which the corresponding bits ...
随机推荐
- js之瀑布流的实现
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- python学习之多线程(二)
使用multiprocessing 使用multiprocessing.dummy 单使用multiprocessing模块的指的是多进程,使用multiprocessing.dummy则表示使用的是 ...
- 2017年 ACM Journal Latex templates 新模板生成 acmart.cls 文件
假定你的文稿在:/user/acmart-master那么cd /user/acmart-masterlatex acmart.ins最后可得到acmart.cls.
- appium-java,切换源生app和webview
方法 public void swith_app(AndroidDriver AndroidDriver){ //切换到源生app System.out.println(AndroidDriver.g ...
- css table 布局 与 JavaScript 指定区域打印功能
<!DOCTYPE html> <html lang="en"><head> <meta http-equiv="conte ...
- GridView合并表头多重表头
后台代码: using System; using System.Data; using System.Configuration; using System.Web; using System.We ...
- elixir 调用erlang 代码
备注: 项目比较简单,主要是elixir 混合erlang 代码,elixir 调用erlang 模块方法 1. 初始化项目 mix new erlangelixirdemo 项目结构如 ...
- 在CentOS上把MySQL从5.5升级到5.6(转)
http://www.th7.cn/db/mysql/201408/66064.shtml 在CentOS上把MySQL从5.5升级到5.6 摘要:本文记录了在CentOS 6.3上,把MySQL从5 ...
- Linux VPS禁止某个IP访问
http://www.vpser.net/security/linux-vps-deny-ip.html
- TOMCATE8下面项目启动问题
1.将servlet-api.jar替换项目中的servlet-api2.4 2.<servlet> <servlet-name>dwr-invoker&l ...