MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / __init__

Method __init__

data_structures/arrays/prefix_sum.py:11–19  ·  view source on GitHub ↗
(self, array: list[int])

Source from the content-addressed store, hash-verified

9
10class PrefixSum:
11 def __init__(self, array: list[int]) -> None:
12 len_array = len(array)
13 self.prefix_sum = [0] * len_array
14
15 if len_array > 0:
16 self.prefix_sum[0] = array[0]
17
18 for i in range(1, len_array):
19 self.prefix_sum[i] = self.prefix_sum[i - 1] + array[i]
20
21 def get_sum(self, start: int, end: int) -> int:
22 """

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected