Range Sum Query - Mutable
A medium-tier problem at 42% community acceptance, tagged with Array, Design, Binary Indexed Tree. Reported in interviews at Google and 0 others.
Range Sum Query - Mutable is the problem where you build a data structure that handles two operations: updating array elements and querying sums over ranges. The twist is that updates happen constantly, so a naive re-sum every query will time out. Google has asked this one, and at 41% acceptance, most candidates either nail the pattern or hit a wall. This is the kind of problem where either you know the trick or you're rewriting code under pressure. If you freeze on the live OA, StealthCoder surfaces a working solution invisible to the proctor.
Companies that ask "Range Sum Query - Mutable"
Range Sum Query - Mutable is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by a senior engineer who knows the OA is theater. This is the script.
Get StealthCoderThe core insight is that you can't store raw sums and recompute on every update, nor can you update one element and recalculate every range. You need a data structure that makes both operations logarithmic. Binary Indexed Tree (Fenwick Tree) and Segment Tree both solve this by organizing the array into a tree where each node caches partial sums. Updates percolate up in log time, and range queries combine cached results in log time. Most candidates either skip the optimization and get TLE, or they memorize one tree type but can't rebuild it under stress. The real challenge isn't the algorithm; it's coding it cleanly without bugs. If this problem appears on your live assessment and you blank on tree construction, StealthCoder runs invisibly and delivers the full working implementation.
Pattern tags
You know the problem.
Make sure you actually pass it.
Range Sum Query - Mutable recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by a senior engineer who knows the OA is theater. This is the script. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Range Sum Query - Mutable interview FAQ
Is a Binary Indexed Tree or Segment Tree easier to implement?+
Binary Indexed Tree is more compact and harder to mess up syntactically, but Segment Tree is more intuitive to visualize. Pick whichever you've drilled. Both solve this problem in O(log n) for update and query. Don't waste OA time deciding.
What if I just recompute the sum every query?+
If you have n updates and q queries, that's O(n*q) worst case. With arrays up to 10^4 or 10^5 and many operations, you'll time out. The problem requires better than linear per operation.
Does Google still ask this at the same frequency?+
Data structure design problems remain standard at top companies. While patterns shift, range query with updates is a classic. High acceptance rate is 50-60% for medium problems; at 41%, this one weeds people out.
How does this relate to Array and Design topics?+
You're designing a custom data structure (Design) that wraps an array (Array). The real work is choosing the right tree abstraction. This tests whether you think beyond linear solutions.
What's the most common mistake?+
Off-by-one errors in tree indexing, especially with 0-indexed vs 1-indexed conventions. Also, updating only the element without propagating changes up the tree. Test edge cases: single element, query at boundaries.
Want the actual problem statement? View "Range Sum Query - Mutable" on LeetCode →