Skip to content

Commit 96985a6

Browse files
committed
fix the coding style to pass code-style check
1 parent 1650272 commit 96985a6

File tree

1 file changed

+35
-35
lines changed

1 file changed

+35
-35
lines changed

Trees/FenwickTree.js

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,44 +6,44 @@
66

77
class FenwickTree {
88
/**
9-
* Constructs a Fenwick Tree.
10-
* @param {Array} fenwickArray The Fenwick Tree array to be initialized.
11-
* @param {Array} array The input array whose prefix sum is to be calculated.
12-
* @param {number} n The size of the input array.
13-
*/
14-
constructor(feneickArray, array, n) {
15-
for (let i = 1; i <= n; i++) {
16-
feneickArray[i] = 0
17-
}
18-
for (let i = 0; i < n; i++) {
19-
this.update(feneickArray, n, i, array[i])
20-
}
21-
}
9+
* Constructs a Fenwick Tree.
10+
* @param {Array} fenwickArray The Fenwick Tree array to be initialized.
11+
* @param {Array} array The input array whose prefix sum is to be calculated.
12+
* @param {number} n The size of the input array.
13+
*/
14+
constructor(feneickArray, array, n) {
15+
for (let i = 1; i <= n; i++) {
16+
feneickArray[i] = 0
17+
}
18+
for (let i = 0; i < n; i++) {
19+
this.update(feneickArray, n, i, array[i])
20+
}
21+
}
2222

2323
/**
24-
* Updates the Fenwick Tree with a new value at the specified index.
25-
* @param {Array} fenwickArray The Fenwick Tree array.
26-
* @param {number} n The size of the Fenwick Tree array.
27-
* @param {number} index The index at which the value is updated.
28-
* @param {number} value The new value to be added at the index.
29-
*/
30-
update(feneickArray, n, index, value) {
31-
index = index + 1
32-
while (index <= n) {
33-
feneickArray[index] += value
34-
index += index & -index
35-
}
36-
}
24+
* Updates the Fenwick Tree with a new value at the specified index.
25+
* @param {Array} fenwickArray The Fenwick Tree array.
26+
* @param {number} n The size of the Fenwick Tree array.
27+
* @param {number} index The index at which the value is updated.
28+
* @param {number} value The new value to be added at the index.
29+
*/
30+
update(feneickArray, n, index, value) {
31+
index = index + 1
32+
while (index <= n) {
33+
feneickArray[index] += value
34+
index += index & -index
35+
}
36+
}
3737

38-
getPrefixSum(feneickArray, index) {
39-
let currSum = 0
40-
index = index + 1
41-
while (index > 0) {
42-
currSum += feneickArray[index]
43-
index -= index & -index
44-
}
38+
getPrefixSum(feneickArray, index) {
39+
let currSum = 0
40+
index = index + 1
41+
while (index > 0) {
42+
currSum += feneickArray[index]
43+
index -= index & -index
44+
}
4545

46-
return currSum
47-
}
46+
return currSum
47+
}
4848
}
4949
export { FenwickTree }

0 commit comments

Comments
 (0)