当前位置:网站首页>LeetCode - 303 区域和检索 - 数组不可变 (设计 前缀和数组)
LeetCode - 303 区域和检索 - 数组不可变 (设计 前缀和数组)
2022-07-25 15:32:00 【三岁就很萌@D】



class NumArray {
private int[] preSum;
public NumArray(int[] nums) {
int n = nums.length;
preSum = new int[n+1];
for(int i = 0; i < n;i++)
preSum[i+1] = preSum[i] + nums[i];
}
public int sumRange(int left, int right) {
return preSum[right+1] - preSum[left];
}
}
边栏推荐
- User defined annotation verification API parameter phone number
- Idea eye care settings
- PageHelper does not take effect, and SQL does not automatically add limit
- matlab randint,Matlab的randint函数用法「建议收藏」
- Node learning
- ML - 语音 - 高级语音模型
- ML - 自然语言处理 - 关键技术
- matlab--CVX优化工具包安装
- Cf685b find the center of gravity of each subtree of a rooted tree
- 盒子躲避鼠标
猜你喜欢

ML - 语音 - 语音处理介绍

ML - 图像 - 深度学习和卷积神经网络

P4552 differential

Phased summary of the research and development of the "library management system -" borrowing and returning "module
SQL cultivation manual from scratch - practical part

p4552-差分

No tracked branch configured for branch xxx or the branch doesn‘t exist. To make your branch trac

Node learning

Cf888g clever dictionary tree + violent divide and conquer (XOR minimum spanning tree)

ML - 语音 - 深度神经网络模型
随机推荐
Brain racking CPU context switching
带你详细认识JS基础语法(建议收藏)
IOS interview questions
获取键盘按下的键位对应ask码
ML - 语音 - 深度神经网络模型
2021 Shanghai match-b-ranked DP
PAT甲级1152 Google Recruitment (20 分)
Node learning
SVD奇异值分解推导及应用与信号恢复
In depth: micro and macro tasks
Xcode添加mobileprovision证书文件报错:Xcode encountered an error
Word 样式模板复制到另一文档
自定义注解校验API参数电话号
2021HNCPC-E-差分,思维
ML - 语音 - 语音处理介绍
p4552-差分
PageHelper does not take effect, and SQL does not automatically add limit
MATLAB 如何生产随机复序列
带你创建你的第一个C#程序(建议收藏)
JVM—类加载器和双亲委派模型