The IPL management wants to calculate the total points scored by a team in a given range of matches. Given an array of scores and a range [start, end], calculate the total points scored by the team in the given range.
Explanation: Step-by-step: with input [10, 20, 30, 40, 50] and range [1, 3], we sum the scores from index 1 to 3, which are 20, 30, and 40, giving a total of 20 + 30 + 40 = 90
Explanation: Step-by-step: with input [5, 15, 25, 35, 45] and range [0, 2], we sum the scores from index 0 to 2, which are 5, 15, and 25, giving a total of 5 + 15 + 25 = 45
Cumulative sum for range queries
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak