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

Lintcode206 Interval Sum solution 题解

时间:2018-02-17 20:30:15      阅读:241      评论:0      收藏:0      [点我收藏+]

标签:参考   lin   cal   inter   zhang   ons   his   pos   ntc   

【题目描述】

 

 

Given an integer array (index from 0 to n-1, where n is the size of this array), and an query list. Each query has two integers[start, end]. For each query, calculate the sum number between index start and end in the given array, return the result list.

Notice:We suggest you finish problem Segment Tree Build,Segment Tree Query and Segment Tree Modify first.

给定一个整数数组(下标由 0 到 n-1,其中 n 表示数组的规模),以及一个查询列表。每一个查询列表有两个整数[start, end]。 对于每个查询,计算出数组中从下标 start 到 end 之间的数的总和,并返回在结果列表中。

【注】:在做此题前,建议先完成以下三题:线段树的构造线段树的查询,以及线段树的修改

【题目链接】

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

【题目解析】

此题可使用区间树解决。注意interval各有一部分处于root左侧和右侧的问题。

【参考答案】

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



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

Lintcode206 Interval Sum solution 题解

标签:参考   lin   cal   inter   zhang   ons   his   pos   ntc   

原文地址:https://www.cnblogs.com/admondguo/p/8452137.html

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