File tree Expand file tree Collapse file tree 1 file changed +15
-15
lines changed Expand file tree Collapse file tree 1 file changed +15
-15
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments