Skip to content

Commit 439c0cc

Browse files
committed
update table of content - counting bits
1 parent 1865969 commit 439c0cc

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

java/counting-bits.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
11
# [Leetcode 338: Counting Bits](https://leetcode.com/problems/counting-bits/)
22

33
## Approaches
4-
- [Approach 1: Naive Approach](#approach-1-naive-approach)
5-
- [Approach 2: DP with Last Significant Bit](#approach-2-dp-with-last-significant-bit)
6-
- [Approach 3: DP with Highest Power of Two](#approach-3-dp-with-highest-power-of-two)
4+
- [Leetcode 338: Counting Bits](#leetcode-338-counting-bits)
5+
- [Approaches](#approaches)
6+
- [Approach 1: Naive Approach](#approach-1-naive-approach)
7+
- [Intuition](#intuition)
8+
- [Code](#code)
9+
- [Time Complexity](#time-complexity)
10+
- [Space Complexity](#space-complexity)
11+
- [Approach 2: DP with Last Significant Bit](#approach-2-dp-with-last-significant-bit)
12+
- [Intuition](#intuition-1)
13+
- [Code](#code-1)
14+
- [Time Complexity](#time-complexity-1)
15+
- [Space Complexity](#space-complexity-1)
16+
- [Approach 3: DP with Highest Power of Two](#approach-3-dp-with-highest-power-of-two)
17+
- [Intuition](#intuition-2)
18+
- [Code](#code-2)
19+
- [Time Complexity](#time-complexity-2)
20+
- [Space Complexity](#space-complexity-2)
721

822
---
923

@@ -83,7 +97,7 @@ public int[] countBits(int n) {
8397
pow *= 2; // Move to the next power of two
8498
x = i;
8599
}
86-
res[i] = res[i-x] + 1; // Use the result from a smaller index plus one
100+
res[i] = res[i - x] + 1; // Use the result from a smaller index plus one
87101
}
88102
return res;
89103
}

0 commit comments

Comments
 (0)