Given an integer array nums, implement sumRange(left, right) which returns the sum of elements from index left to right (inclusive). Use prefix sums for O(1) queries.
Example: nums = [-2,0,3,-5,2,-1] sumRange(0,2) = 1 sumRange(2,5) = -1 sumRange(0,5) = -3
Jnaneshwara Reddy Satti
Builder · ClearCode
Hi — I'm a 21yo CS grad from India. I built ClearCode while recovering from a surgery, because I genuinely believe DSA should be visual, free, and accessible to everyone. No VC funding. No team. Just me, my laptop, and a lot of chai. ☕
If ClearCode helped you understand even one concept — consider supporting it. Every rupee keeps the servers running and new videos coming.