# leetcode 231: Power of Two

### Power of Two

Total Accepted: 3596 Total Submissions: 11779

Given an integer, write a function to determine if it is a power of two.

Credits:
Special thanks to @jianchao.li.fighter for adding this problem and creating all test cases.

[思路]

[CODE]

public class Solution {
public boolean isPowerOfTwo(int n) {
return n > 0 && ((n & (n - 1)) == 0 );
}
}

• 本文已收录于以下专栏：

## leetcode 231. Power of Two 判断是否为2的幂 Java

231. Power of Two Given an integer, write a function to determine if it is a power of two. Credit...

## [LeetCode] Power of Three | Power of Two

Given an integer, write a function to determine if it is a power of three.Follow up: Could you do i...

## LeetCode 231: Power of Two

Given an integer, write a function to determine if it is a power of two. 判断一个数是否是2的幂，判断方法主要依据2的...

## Leetcode#231_power of two

﻿﻿ 题目链接:https://leetcode.com/problems/power-of-two/ 大意是给一个整数，判断它是不是2的N(N>=0，整数)次方。 一开始我的想法是将它转换成2...

## [LeetCode-231] Power of Two（判断一个数是不是2的若干次幂）

Given an integ这里写代码片er, write a function to determine if it is a power of two.【分析】如果一个数是2的若干次幂，那么二进制...

## 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. 判断一个整数是不是2的次方： class Solu...

## LeetCode 231. Power of Two 解题报告

LeetCode 231. Power of Two 解题报告

## [231] Power of Two

• camlot_
• 2016年06月25日 19:50
• 162

## Leetcode 231. Power of Two & 326. Power of Three & 342. Power of Four

231. Power of Two   Total Accepted: 69528 Total Submissions: 190898 Difficulty: Easy Given an ...

举报原因： 您举报文章：leetcode 231: Power of Two 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)