231 Power of Two
位运算
public class Solution {
public boolean isPowerOfTwo(int n) {
return n > 0 && ((n & (n - 1)) == 0 );
}
}
位运算
public class Solution {
public boolean isPowerOfTwo(int n) {
return n > 0 && ((n & (n - 1)) == 0 );
}
}
[welcome to my blog][] LeetCode Top Interview Questions 231. Power of Two (Java版; Ea
Given an integer, write a function to determine if it is a power of two. Example 1:
题目描述: 给定一个整数,编写一个函数来判断它是否是 2 的幂次方。 示例 1: 输入: 1 输出: true 解释: 20 = 1 示例 2: 输入: 1
/ @param {number} n @return {boolean} / var isPowerOfTwo = function(n) {
Problem: > Given an integer, write a function to determine if it is a power of two. An
位运算 public class Solution { public boolean isPowerOfTwo(int n) {
231. Power of Two(另一种特殊求法) Given an integer, write a function to determine if it is a
Given an integer, write a function to determine if it is a power of two. public cla
1.题目 Given an integer, write a function to determine if it is a power of two. 判断一个整
/\ Given an integer, write a function to determine if it is a power of two. \/
还没有评论,来说两句吧...