1
0
Fork 0
mirror of https://gitlab.com/mfocko/LeetCode.git synced 2024-11-09 15:59:06 +01:00

rs: add «231. Power of Two»

Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
Matej Focko 2024-02-19 14:04:14 +01:00
parent 66a146f17f
commit 2f10b3cfbc
Signed by: mfocko
GPG key ID: 7C47D46246790496

5
rs/power-of-two.rs Normal file
View file

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