diff --git a/maths/power_of_two.rb b/maths/power_of_two.rb index 5d514be..2eb24a8 100644 --- a/maths/power_of_two.rb +++ b/maths/power_of_two.rb @@ -119,6 +119,11 @@ puts is_power_of_two(n) # Approach 4: Bitwise operators: Turn off the Rightmost 1-bit # +# Note that there are two ways of solving this problem via bitwise operations: +# 1. How to get / isolate the rightmost 1-bit: x & (-x). +# 2. How to turn off (= set to 0) the rightmost 1-bit: x & (x - 1). +# In this approach, we're reproducing item 2. + # Complexity Analysis # # Time complexity: O(1).