Skip to content

Commit 15cd63c

Browse files
committed
Fix Multiple Variable Declarations
1 parent 3fe46ba commit 15cd63c

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/main/java/com/thealgorithms/tree/HeavyLightDecomposition.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,10 @@
55

66
/**
77
* Heavy-Light Decomposition (HLD) implementation in Java.
8-
*
98
* HLD is used to efficiently handle path queries on trees, such as maximum,
109
* sum, or updates. It decomposes the tree into heavy and light chains,
1110
* enabling queries in O(log N) time.
12-
*
1311
* Wikipedia Reference: https://en.wikipedia.org/wiki/Heavy-light_decomposition
14-
*
1512
* Author: Nithin U.
1613
* Github: https://github.com/NithinU2802
1714
*/
@@ -67,7 +64,8 @@ private void dfsSize(int node, int parentNode) {
6764
private void decompose(int node, int head) {
6865
chainHead[node] = head;
6966
position[node] = positionIndex++;
70-
int heavyChild = -1, maxSubtreeSize = -1;
67+
int heavyChild = -1;
68+
int maxSubtreeSize = -1;
7169
for (int child : tree[node]) {
7270
if (child != parent[node] && subtreeSize[child] > maxSubtreeSize) {
7371
heavyChild = child;

0 commit comments

Comments
 (0)