In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how leetcode solves the immutable problem of regions and retrieval arrays. I hope you will get something after reading this article. Let's discuss it together.
I. the content of the topic
Given an integer array nums, find the sum of the elements in the array from index I to j (I ≤ j), including I and j points.
Implement the NumArray class:
NumArray (int [] nums) initializes objects using array nums
Int sumRange (int I, int j) returns the sum of the elements in the array nums from index I to j (I ≤ j), including I and j points (that is, sum (nums [I], nums [I + 1],..., nums [j]))
Example:
Enter:
["NumArray", "sumRange", "sumRange", "sumRange"]
[[- 2, 0, 3,-5, 2,-1]], [0, 2], [2, 5], [0, 5]]
Output:
[null, 1,-1,-3]
Explanation:
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))
Tip:
0
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.