专栏名称: 每日一道算法题
学习算法是一种信仰,每天都需要坚持!
目录
相关文章推荐
算法爱好者  ·  DeepSeek 下棋靠忽悠赢了 ... ·  1小时前  
算法与数学之美  ·  数学大家丘成桐主编的科普读物:中国孩子要培养 ... ·  15 小时前  
九章算法  ·  Cruise被迫裁员50%!高额遣散费打脸科 ... ·  2 天前  
算法爱好者  ·  为 DeepSeek 辟谣:五大误解与真相解读 ·  2 天前  
九章算法  ·  升到L6,谈谈今年的情况 ·  3 天前  
51好读  ›  专栏  ›  每日一道算法题

[每日一题]307. Range Sum Query - Mutable

每日一道算法题  · 公众号  · 算法  · 2017-10-24 22:53

正文

亲爱的老铁们,你们辛苦了。1024, 节日

快乐。


Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.


The update(i, val) function modifies nums by updating the element at index i to val.

Example:

Given nums = [1, 3, 5]


sumRange(0, 2) -> 9

update(1, 2)

sumRange(0, 2) -> 8

Note:

The array is only modifiable by the update function.

You may assume the number of calls to update and sumRange function is distributed evenly.


提示:提交代码后,需要用简洁的语言解释一下代码思路~ 谢谢


历史题目和总结见公众号「每日一道算法题」


https://leetcode.com/problems/range-sum-query-mutable/description/








请到「今天看啥」查看全文