quartz/content/tmp_script/prefix_sum.md
2024-02-27 19:32:43 +08:00

16 lines
296 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: Prefix Sum
tags:
- basic
---
假设我们有一个长度为n的数组arr**前缀和**数组prefixSum的定义如下
```python
prefixSum[0] = arr[0]
prefixSum[1] = arr[0] + arr[1]
prefixSum[2] = arr[0] + arr[1] + arr[2]
...
prefixSum[i] = arr[0] + arr[1] + ... + arr[i]
```