Lintcode207 Interval Sum II solution 题解

 

【题目描述】

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://my.oschina.net/u/3776581/blog/1617757

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值