Skip to content

Commit

Permalink
impl power of two
Browse files Browse the repository at this point in the history
  • Loading branch information
SKTT1Ryze committed Apr 16, 2024
1 parent 6997847 commit 520ef83
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion leetcode-rs/src/solutions/power_of_two.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ crate::derive_solution!(

impl SolutionImpl {
pub fn is_power_of_two(n: i32) -> bool {
todo!()
if n == 1 {
true
} else if n == 0 {
false
} else {
n % 2 == 0 && Self::is_power_of_two(n / 2)
}
}
}

0 comments on commit 520ef83

Please sign in to comment.