当前位置:网站首页>303. region and retrieval - array immutable
303. region and retrieval - array immutable
2022-06-23 07:08:00 【Graduation_ Design】
Preface
C++ It's a high-level programming language , from C Language expansion and upgrading , As early as 1979 By Benjani · Strauss LUP is AT&T Developed by Bell studio .
C++ Both can be carried out C Process programming of language , It can also be used for object-based programming characterized by abstract data types , It can also carry out object-oriented programming characterized by inheritance and polymorphism .C++ Good at object-oriented programming at the same time , You can also do process based programming .
C++ Have the practical characteristics of computer operation , At the same time, it is also committed to improving the programming quality of large-scale programs and the problem description ability of programming languages .
Java Is an object-oriented programming language , Not only absorbed C++ The advantages of language , It's abandoned C++ The incomprehensible inheritance in 、 Concepts such as pointer , therefore Java Language has two characteristics: powerful and easy to use .Java As the representative of static object-oriented programming language , Excellent implementation of object-oriented theory , Allow programmers to do complex programming in an elegant way of thinking .
Java It's simple 、 object-oriented 、 Distributed 、 Robustness, 、 Security 、 Platform independence and portability 、 Multithreading 、 Dynamic and so on .Java Can write desktop applications 、Web Applications 、 Distributed system and embedded system applications, etc .
Python By Guido of the Dutch Society for mathematical and computer science research · Van rosum On 1990 It was designed in the early 's , As a course called ABC A substitute for language .Python Provides efficient advanced data structure , It's also a simple and effective way of object-oriented programming .Python Syntax and dynamic types , And the nature of interpretative language , Make it a programming language for scripting and rapid application development on most platforms , With the continuous update of the version and the addition of new language features , Gradually used for independent 、 Development of large projects .
Python The interpreter is easy to extend , have access to C Language or C++( Or something else can be done through C Calling language ) Expand new functions and data types .Python It can also be used as an extensible programming language in customizable software .Python Rich library of standards , Provides source code or machine code for each major system platform .
2021 year 10 month , Compiler for language popularity index Tiobe take Python Crowned the most popular programming language ,20 Put it in... For the first time in years Java、C and JavaScript above .
describe
Given an array of integers nums, Handle multiple queries of the following types :
Calculation index left and right ( contain left and right) Between nums Elemental and , among left <= right
Realization NumArray class :
NumArray(int[] nums) Using arrays nums Initialize object
int sumRange(int i, int j) Returns an array of nums Middle index left and right Between elements The sum of the , contain left and right At two o 'clock ( That is to say nums[left] + nums[left + 1] + ... + nums[right] )
Example 1:
Input :
["NumArray", "sumRange", "sumRange", "sumRange"]
[[[-2, 0, 3, -5, 2, -1]], [0, 2], [2, 5], [0, 5]]
Output :
[null, 1, -1, -3]
explain :
NumArray numArray = new NumArray([-2, 0, 3, -5, 2, -1]);
numArray.sumRange(0, 2); // return 1 ((-2) + 0 + 3)
numArray.sumRange(2, 5); // return -1 (3 + (-5) + 2 + (-1))
numArray.sumRange(0, 5); // return -3 ((-2) + 0 + 3 + (-5) + 2 + (-1))
class NumArray {
int[] sums;
public NumArray(int[] nums) {
int n = nums.length;
sums = new int[n + 1];
for (int i = 0; i < n; i++) {
sums[i + 1] = sums[i] + nums[i];
}
}
public int sumRange(int i, int j) {
return sums[j + 1] - sums[i];
}
}
边栏推荐
- 小白投资理财必看:图解基金买入与卖出规则
- MySQL index
- 309. 最佳买卖股票时机含冷冻期
- 产品-Axure9(英文版),原型设计 制作下拉二级菜单
- [project training 10] drawing of arrows
- 301. 删除无效的括号
- 316. remove duplicate letters
- /Bin/sh no such file or directory problem
- 【日常训练】513. 找树左下角的值
- redux Actions may not have an undefined “type“ property. Have you misspelled a constant?
猜你喜欢

Why does TCP protocol shake hands three times instead of two?

Idea automatically generates serialVersionUID

【STL】顺序容器之deque用法总结

MySQL mvcc multi version concurrency control

MySQL重做日志 redo log

Solve the mining virus sshd2 (redis does not set a password and clear the crontab scheduled task)

MySQL optimization

【项目实训】线形箭头的变化

小白投资理财必看:图解基金买入与卖出规则

Intentional shared lock, intentional exclusive lock and deadlock of MySQL
随机推荐
900. RLE iterator
Endnote20 tutorial sharing (unfinished
初始化层实现
[project training 10] drawing of arrows
MySQL basic query
Chrome remove duplicate bookmarks
Some difficulties in making web pages
316. remove duplicate letters
关于五险一金你需要知道的事情
【项目实训】线形组件的细节
MySQL function
【STL】顺序容器之deque用法总结
[STL] unordered of associated container_ Map Usage Summary
聚焦行业,赋能客户 | 博云容器云产品族五大行业解决方案发布
Influence of steam education on domestic college students
[STL] summary of stack and queue usage of container adapter
Intentional shared lock, intentional exclusive lock and deadlock of MySQL
js 判断两个数组增加和减少的元素
QT method of compiling projects using multithreading
Idea installing the cloudtoolkit plug-in