algorithm: SegmentTree (#1178)

This commit is contained in:
Changi Cho
2022-10-20 20:39:37 +09:00
committed by GitHub
parent 636017ca51
commit 58671861a5
2 changed files with 113 additions and 0 deletions

View File

@ -0,0 +1,16 @@
import { SegmentTree } from '../SegmentTree'
describe('SegmentTree sum test', () => {
const a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
const segment = new SegmentTree(a)
it('init sum check', () => {
expect(segment.query(0, 2)).toBe(6)
})
it('init sum check', () => {
segment.update(2, 1)
expect(segment.query(0, 2)).toBe(4)
})
})