1
0
Fork 0
mirror of https://gitlab.com/mfocko/LeetCode.git synced 2024-11-10 00:09:06 +01:00
LeetCode/rs/power-of-two.rs
Matej Focko 2f10b3cfbc
rs: add «231. Power of Two»
Signed-off-by: Matej Focko <mfocko@redhat.com>
2024-02-19 14:04:14 +01:00

5 lines
105 B
Rust

impl Solution {
pub fn is_power_of_two(n: i32) -> bool {
n > 0 && ((n - 1) & n) == 0
}
}