LeetCode
KeepGoingPawn
KeepGoingPawn
展开
-
【LeetCode】-powerOfTwo
【Description:】231. Power of Two Easy Given an integer, write a function to determine if it is a power of two. 给定一个整型数,判断是否是2的倍数。 Example 1: Input: 1 Output: true Explanation: 20 = 1 Example 2: I...原创 2019-05-08 15:17:11 · 137 阅读 · 0 评论 -
【LeetCode】-hammingWeight
计算无符号整型数n中有多少个1 【难度:Easy】 思路: 定义一个变量count用来记录1的次数; n 每次与1 做&运算,结果为1则count++, 因为n是整型 32位,所以循环32次 循环中每次n无符号右移1位 n = n>>>1; 代码实现: public static int hammingWeight(int n) { ...原创 2019-05-08 15:02:41 · 234 阅读 · 1 评论 -
【LeetCode】-reverse-bits
通用解法:https://www.cnblogs.com/grandyang/p/4321355.html 高票回答:https://leetcode.com/problems/reverse-bits/discuss/54741/ 此篇文章讲了一下通用的解法。我主要是分析一下高票的那种解法: package algorithms; /** * @Author:Kevin * @Descri...原创 2019-05-07 18:23:01 · 160 阅读 · 0 评论