参见 307. Range Sum Query - Mutable
Segment Tree
Tree Implementation (SegmentTreeNode)
https://www.youtube.com/watch?v=rYBtViWXYeI&list=PLLuMmzMTgVK7ug02DDoQsf50OtwVDL1xd&index=1
https://leetcode.com/problems/range-sum-query-mutable/discuss/75711/C++-Segment-Treeupdate-and-sum-are-both-O(logn)
Array Implementation
Since a Segment Tree is a binary tree, a simple linear array can be used to represent the Segment Tree.
https://leetcode.com/articles/a-recursive-approach-to-segment-trees-range-sum-queries-lazy-propagation/
https://www.hackerearth.com/zh/practice/data-structures/advanced-data-structures/segment-trees/tutorial/
原文地址:https://www.cnblogs.com/hankunyan/p/11188273.html
时间: 2024-11-03 23:48:59