Update the values in the segment tree in the range [a,b] with the given value. >>> s = SegmentTree([1, 2, 3, 4, 5]) >>> s.update(2, 4, 10) True >>> s.query(1, 5) 10
(self, a, b, val)
| 45 | self.st[idx] = max(self.st[self.left(idx)], self.st[self.right(idx)]) |
| 46 | |
| 47 | def update(self, a, b, val): |
| 48 | """ |
| 49 | Update the values in the segment tree in the range [a,b] with the given value. |
| 50 | |
| 51 | >>> s = SegmentTree([1, 2, 3, 4, 5]) |
| 52 | >>> s.update(2, 4, 10) |
| 53 | True |
| 54 | >>> s.query(1, 5) |
| 55 | 10 |
| 56 | """ |
| 57 | return self.update_recursive(1, 0, self.N - 1, a - 1, b - 1, val) |
| 58 | |
| 59 | def update_recursive(self, idx, left, right, a, b, val): |
| 60 | """ |
no test coverage detected