Segment Tree & Range Queries/Medium

Range Sum Query - MutablePRO PASS

Time: O(log N) per querySpace: O(N)

Step 1: Setup & Initialization - Segment Tree

Recursively divide array range into left and right tree segments.

Array Elements & Pointers
10
[0]
20
[1]
30
[2]
40
[3]
50
[4]
Live Variables & Invariants
status:Initialized
pattern:Segment Tree
Step 1 / 333%
Solution Code
1
class NumArray { tree: number[]; n: number; constructor(nums: number[]) { this.n = nums.length; this.tree = new Array(4 * this.n).fill(0); } }

Custom Test Case Runner

Input your custom values and visualize step-by-step trace

Quick Presets:

AI DSA Coach

Contextual Tutor for Range Sum Query - Mutable

Hello! I am your AI DSA Tutor for **Range Sum Query - Mutable** (Segment Tree & Range Queries). Ask me anything about this algorithm, time complexity, or request a step hint!