leetcode 231 Power of Two(难易度:Easy)

来源:互联网 发布:c语言for的用法 编辑:程序博客网 时间:2024/06/05 21:56

Power of Two

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

代码:

bool isPowerOfTwo(int n) {    return (n > 0) && (!(n &(n - 1)));}
原题地址:https://leetcode.com/problems/power-of-two/


0 0
原创粉丝点击