Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8661451

Browse files
committed
formatting
1 parent fb6dce2 commit 8661451

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/data_structures/fenwick.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -471,24 +471,24 @@ We can find arbitrary range sums by computing the prefix sums for $l-1$ and $r$
471471
b[idx] += x
472472
idx += idx & -idx
473473

474-
def range_add(l,r,x):
475-
add(B1, l, x)
476-
add(B1, r + 1, -x)
477-
add(B2, l, x * (l - 1))
478-
add(B2, r + 1, -x * r)
474+
def range_add(l,r,x):
475+
add(B1, l, x)
476+
add(B1, r + 1, -x)
477+
add(B2, l, x * (l - 1))
478+
add(B2, r + 1, -x * r)
479479

480-
def sum(b, idx):
481-
total = 0
482-
while idx > 0:
483-
total += b[idx]
484-
idx -= idx & -idx
485-
return total
480+
def sum(b, idx):
481+
total = 0
482+
while idx > 0:
483+
total += b[idx]
484+
idx -= idx & -idx
485+
return total
486486

487-
def prefix_sum(idx):
488-
return sum(B1, idx) * idx - sum(B2, idx)
487+
def prefix_sum(idx):
488+
return sum(B1, idx) * idx - sum(B2, idx)
489489

490-
def range_sum(l, r):
491-
return prefix_sum(r) - prefix_sum(l - 1)
490+
def range_sum(l, r):
491+
return prefix_sum(r) - prefix_sum(l - 1)
492492
```
493493

494494
## Practice Problems

0 commit comments

Comments
 (0)