码迷,mamicode.com
首页 > 其他好文 > 详细

Lintcode207 Interval Sum II solution 题解

时间:2018-02-20 15:57:51      阅读:201      评论:0      收藏:0      [点我收藏+]

标签:题解   查询   结合   简单的   修改   blank   index   problem   商业   

【题目描述】

 

 

Given an integer array in the construct method, implement two methods query(start, end) and modify(index, value):

For query(start,end), return the sum from index start to index end in the given array.

For modify(index,value), modify the number in the given index tovalue

Notice

We suggest you finish problem Segment Tree Build,Segment Tree Query andSegment Tree Modify first.

在类的构造函数中给一个整数数组, 实现两个方法query(start, end)和modify(index, value):

对于 query(start,end), 返回数组中下标startend

对于 modify(index,value), 修改数组中下标为index上的数为value.

【注】在做此题前,建议先完成以下三题:

线段树的构造

线段树的查询

线段树的修改

【题目链接】

www.lintcode.com/en/problem/interval-sum-ii/

【题目解析】

此题属于比较简单的题目,同[Interval Sum I]的思路类似,可把query sum和modify结合起来即可解决问题。

【参考答案】

www.jiuzhang.com/solutions/interval-sum-ii/



作者:程风破浪会有时
链接:https://www.jianshu.com/p/7b7d7d5d151c
來源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

Lintcode207 Interval Sum II solution 题解

标签:题解   查询   结合   简单的   修改   blank   index   problem   商业   

原文地址:https://www.cnblogs.com/5245a/p/8450405.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!