当前位置:网站首页>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];
}
}
边栏推荐
- LeetCode - 225 用队列实现栈
- Window system black window redis error 20creating server TCP listening socket *: 6379: listen: unknown error19-07-28
- Pat grade a 1153 decode registration card of PAT (25 points)
- LeetCode - 622 设计循环队列 (设计)
- ML - natural language processing - Introduction to natural language processing
- 组件化和模块化
- 2021 Shanghai match-b-ranked DP
- 2016CCPC网络选拔赛C-换根dp好题
- JVM knowledge brain map sharing
- mouseover和mouseenter的区别
猜你喜欢
随机推荐
Graph theory and concept
Xcode added mobileprovision certificate file error: Xcode encoded an error
IOS interview questions
In depth: micro and macro tasks
Are you ready to break away from the "involution circle"?
JS URLEncode function
No tracked branch configured for branch xxx or the branch doesn‘t exist. To make your branch trac
Solve the vender-base.66c6fc1c0b393478adf7.js:6 typeerror: cannot read property 'validate' of undefined problem
LeetCode - 707 设计链表 (设计)
微信小程序
Deadlock gossip
2019 Shaanxi provincial competition j-bit operation + greed
Flex 布局
SQL cultivation manual from scratch - practical part
See a lot of blinking pictures on apps, especially the member page
LeetCode - 677 键值映射(设计)*
Get the ask code corresponding to the key pressed by the keyboard
Gary marcus: learning a language is more difficult than you think
C # fine sorting knowledge points 9 Set 2 (recommended Collection)
我想问下变量配置功能是只能在SQL模式下使用吗









