PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Molocoads

Support Dynamic Range Sums

Last updated: Apr 16, 2026

Quick Overview

This question evaluates knowledge of data structures and algorithmic techniques for range queries and dynamic updates, along with complexity analysis for time and space.

  • hard
  • Molocoads
  • Coding & Algorithms
  • Software Engineer

Support Dynamic Range Sums

Company: Molocoads

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: hard

Interview Round: Onsite

Implement a data structure over an integer array `nums`. Part 1: If the array never changes, support `sumRange(left, right)` that returns the sum of elements from index `left` to `right`, inclusive. Part 2 (follow-up): Now the array is mutable. Support both: - `update(index, value)`: set `nums[index] = value` - `sumRange(left, right)`: return the inclusive range sum Design the mutable version so that both operations are efficient when the array length and number of operations can each be up to 100,000. Be prepared to discuss multiple approaches and their tradeoffs.

Quick Answer: This question evaluates knowledge of data structures and algorithmic techniques for range queries and dynamic updates, along with complexity analysis for time and space.

Related Interview Questions

  • Can you visit all rooms and score parentheses? - Molocoads (medium)
  • Simulate bubble elimination and maximize common prefix - Molocoads (medium)
  • Find single element when others repeat k times - Molocoads (hard)
  • Compute subarray span for each element - Molocoads (hard)
Molocoads logo
Molocoads
Apr 12, 2026, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
1
0

Implement a data structure over an integer array nums.

Part 1: If the array never changes, support sumRange(left, right) that returns the sum of elements from index left to right, inclusive.

Part 2 (follow-up): Now the array is mutable. Support both:

  • update(index, value) : set nums[index] = value
  • sumRange(left, right) : return the inclusive range sum

Design the mutable version so that both operations are efficient when the array length and number of operations can each be up to 100,000. Be prepared to discuss multiple approaches and their tradeoffs.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Molocoads•More Software Engineer•Molocoads Software Engineer•Molocoads Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.