Skip to content

Commit eb80355

Browse files
Update algorithms/dynamic_programming/countingbits/README.md
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent dce0b1c commit eb80355

File tree

1 file changed

+1
-3
lines changed
  • algorithms/dynamic_programming/countingbits

1 file changed

+1
-3
lines changed

algorithms/dynamic_programming/countingbits/README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ When the number is odd,
5151
- rightmost bit = 1
5252
- rest of bits = 10, which is also (5 // 2) = 2 in binary.
5353

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.
5755
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.
5856
The number of 1's in 4 is the number of 1's in 2 plus 0, because 4 is even.
5957

0 commit comments

Comments
 (0)