
OJ算法-位操作
文章平均质量分 84
BraveLii
这个作者很懒,什么都没留下…
展开
-
剑指offer-15、二进制中1的个数
题目描述输入一个整数,输出该数二进制表示中1的个数。其中负数用补码表示。思路:1、n-1,可以把第1个(从右往左)为1的数变成0,其右的0变成12、n &=(n-1)的作用就是把数字n的第1各为1的数字变成0class Solution { public: int NumberOf1(int n) { int count = 0; while...原创 2018-05-01 11:16:18 · 182 阅读 · 0 评论 -
LeetCode-不重复的数字
1、不重复的数字(LeetCode-136)Given a non-empty array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you imple...原创 2018-04-21 14:39:59 · 1209 阅读 · 0 评论