MCPcopy Create free account
hub / github.com/LjyYano/LeetCode / isPowerOfTwo

Method isPowerOfTwo

src/main/java/L0231_PowerOfTwo.java:40–48  ·  view source on GitHub ↗

使用位运算判断一个数是否是 2 的幂 2 的幂在二进制表示中有且仅有一个 1 因此可以使用 n & (n-1) == 0 来判断

(int n)

Source from the content-addressed store, hash-verified

source not stored for this graph (policy: none)

Callers 1

mainMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected