Code RoomRange update point query
MediumPrep Room Coding #119

Range update point query

CodingDatabases & SQLAlgorithms & data structuresMid–Senior~30 min

Maintain an array of `n` integers, all initially 0, supporting two operations given in `ops` (0-indexed): `["u", l, r, delta]` adds `delta` to every element in the inclusive range [l, r], and `["q", i]` returns the current value at index i. Return the answers to the query operations in order. Both operations must run in O(log n). `1 <= n <= 100000`, `len(ops) <= 100000`.

Implement
fenwick_range_update(n: int, ops: list[list]) → list[int]
Examples
in[5,[["u",1,3,2],["q",2],["q",4]]]out[2,0]
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 30 min
InputExpectedGot
[5,[["u",1,3,2],["q",2],["q",4]]][2,0]not run yetsample