Code RoomFenwick tree range updates
MediumPrep Room Coding #873

Fenwick tree range updates

CodingAlgorithms & data structuresMid–Senior~25 min

Maintain a Fenwick (binary indexed) tree over an initial integer array arr. Process operations: ["update", i, v] SETS arr[i] = v (an assignment, not an increment), and ["query", l, r] returns the sum of the inclusive range [l, r]. Indices are 0-based. Return the list of answers to the "query" operations, in order.

Implement
fenwick_point_update_range_sum(arr: list[int], ops: list[list]) → list[int]
Examples
in[[1,2,3,4,5],[["query",0,4],["update",2,10],["query",0,4],["query",2,2]]]out[15,22,10]
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 25 min
InputExpectedGot
[[1,2,3,4,5],[["query",0,4],["update",2,10],["query",0,4],["query",2,2]]][15,22,10]not run yetsample