当前位置:网站首页>Leetcode - 303 area and retrieval - array immutable (design prefix and array)
Leetcode - 303 area and retrieval - array immutable (design prefix and array)
2022-07-25 15:40:00 【Cute at the age of three @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];
}
}
边栏推荐
- 谷歌博客:采用多重游戏决策Transformer训练通用智能体
- 解决vender-base.66c6fc1c0b393478adf7.js:6 TypeError: Cannot read property ‘validate‘ of undefined问题
- matlab randint,Matlab的randint函数用法「建议收藏」
- SVD奇异值分解推导及应用与信号恢复
- Cf566a greed + dictionary tree
- 2021上海市赛-D-卡特兰数变种,dp
- Distributed principle - what is a distributed system
- 2019浙江省赛C-错排问题,贪心
- MySQL优化总结二
- 数据系统分区设计 - 请求路由
猜你喜欢

Games101 review: linear algebra

Geogle Colab笔记1--运行Geogle云端硬盘上的.py文件

Use cpolar to build a business website (how to buy a domain name)

理解“平均负载”

GAMES101复习:线性代数

谷歌博客:采用多重游戏决策Transformer训练通用智能体

Gary marcus: learning a language is more difficult than you think

盒子躲避鼠标

Idea eye care settings

LeetCode - 362 敲击计数器(设计)
随机推荐
< stack simulation recursion >
LeetCode - 232 用栈实现队列 (设计 双栈实现队列)
2019 Shaanxi provincial competition j-bit operation + greed
2016CCPC网络选拔赛C-换根dp好题
See a lot of blinking pictures on apps, especially the member page
Week303 of leetcode
Pytorch学习笔记--Pytorch常用函数总结1
LeetCode - 641 设计循环双端队列(设计)*
Endnote 无法编辑range 解决
2021 Shanghai match-b-ranked DP
I want to ask whether the variable configuration function can only be used in SQL mode
C#精挑整理知识要点11 委托和事件(建议收藏)
2021上海市赛-B-排序后dp
Pytorch框架练习(基于Kaggle Titanic竞赛)
Take you to create your first C program (recommended Collection)
matlab 优化工具 manopt 安装
Hdu3873 shortest path with dependency (topological sorting)
理解“平均负载”
自定义注解校验API参数电话号
ML - natural language processing - Basics