You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: algorithms/dynamic_programming/countingbits/README.md
+1-3Lines changed: 1 addition & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -51,9 +51,7 @@ When the number is odd,
51
51
- rightmost bit = 1
52
52
- rest of bits = 10, which is also (5 // 2) = 2 in binary.
53
53
54
-
in the binary representation of i is that number plus 1 if the rightmost bit is 1. We can tell if the last significant
55
-
bit is 1 by checking if it is odd.
56
-
54
+
The number of 1's in the binary representation of i is the count from i // 2 plus 1 if the rightmost bit is 1. We can tell if the least significant bit is 1 by checking if the number is odd.
57
55
As an example, we know that the number of 1's in 2 is 1. This information can be used to calculate the number of 1's in 4.
58
56
The number of 1's in 4 is the number of 1's in 2 plus 0, because 4 is even.
0 commit comments