Range|Range Sum Query - Immutable
Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.
Example:
Given nums = [-2, 0, 3, -5, 2, -1]
【Range|Range Sum Query - Immutable】sumRange(0, 2) -> 1
sumRange(2, 5) -> -1
sumRange(0, 5) -> -3
Note:
You may assume that the array does not change.
There are many calls to sumRange function.
Careful of timeout.
struct NumArray { int size;
int *sum;
};
/** Initialize your data structure here. */
struct NumArray* NumArrayCreate(int* nums, int numsSize) { struct NumArray* numArray;
numArray=(struct NumArray*)calloc(1,sizeof(struct NumArray));
numArray->sum=(int*)calloc(numsSize+1, sizeof(int));
numArray->size=numsSize;
numArray->sum[0]=0;
for(int i=0;
i
推荐阅读
- web端|web全栈开发(web前后端数据交互。html5+jquery作为前端、Python+flask作为后端)
- sequelize.query 原始查询
- Spring|Spring Data JPA 在 @Query 中使用投影的方法
- 原生js实现each方法
- jquery|b站视频-尚硅谷jQuery教程张晓飞老师-笔记
- jquery参考笔记
- jQuery的功能
- 代码实例效果精选|哈哈哈 原来使用jQuery+CSS就可以实现图片自动切换轮播效果是那么简单的事情 搞了个小米商城官网淡入淡出自动轮播图效果来看看也挺好
- 递归匿名函数手动实现 http_build_query 系统函数
- Use of undefined constant WP_ADMIN - assumed ‘WP_ADMIN‘