rs: add «231. Power of Two»
Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
parent
66a146f17f
commit
2f10b3cfbc
1 changed files with 5 additions and 0 deletions
5
rs/power-of-two.rs
Normal file
5
rs/power-of-two.rs
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
impl Solution {
|
||||||
|
pub fn is_power_of_two(n: i32) -> bool {
|
||||||
|
n > 0 && ((n - 1) & n) == 0
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue