303 Range Sum Query
来源:互联网 发布:用c语言写九九乘法口诀 编辑:程序博客网 时间:2024/05/22 04:58
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]sumRange(0, 2) -> 1sumRange(2, 5) -> -1sumRange(0, 5) -> -3
Note:
- You may assume that the array does not change.
- There are many calls to sumRange function.
class NumArray {public: NumArray(vector<int> nums) : psum(nums.size()+1, 0){ partial_sum( nums.begin(), nums.end(), psum.begin()+1); } int sumRange(int i, int j) { return psum[j+1] - psum[i]; }private: vector<int> psum;};
阅读全文
0 0
- 303,Range Sum Query
- 303 Range Sum Query
- 303+304. Range Sum Query && Range Sum Query 2D
- [303]Range Sum Query - Immutable
- Leetcode 303 Range Sum Query
- Leetcode 303 Range Sum Query
- LeetCode 303 Range Sum Query
- [leetcode-303]Range Sum Query - Immutable
- [leetcode-303]Range Sum Query - Immutable(java)
- leetcode 303: Range Sum Query - Immutable
- Range Sum Query - Immutable leetcode 303
- leetcode 303 : Range Sum Query - Immutable
- LeetCode 303 : Range Sum Query - Immutable (Java)
- LeetCode(303)Range Sum Query - Immutable
- [leetcode 303] Range Sum Query - Immutable
- 【LeetCode】303 Range Sum Query - Immutable
- 【LEETCODE】303-Range Sum Query - Immutable
- LeetCode 303:Range Sum Query - Immutable
- 全面解析Linux 内核 3.10.x
- SONET/SDH
- Spring Boot实战学习笔记2
- 10-rabbitmq-消息主题-spring
- live555学习之基本类介绍及计划任务深度探讨
- 303 Range Sum Query
- SpringMVC面试
- MYSQL基础
- linux使用ss的网络配置
- Spring面试
- 用于 Android 开发的 Kotlin:是重量级语言还是毫无意义的炒作?
- 程序员的自我修养——读《软技能-代码之外的生存指南》笔记
- java面试
- 51nod 1160 压缩算法的矩阵