BackeasyArrays Cognizant

Calculating Total Points Scored by a Team in a Series of Matches Solution

Problem Statement

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.

Example 1
Input
[10, 20, 30, 40, 50], 1, 3
Output
60

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

Example 2
Input
[5, 15, 25, 35, 45], 0, 2
Output
45

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

Constraints

  • The number of matches played by the team does not exceed 10^5.
  • The points scored by the team in each match do not exceed 10^4.
  • The range of matches is always valid and within the bounds of the array of points scored.
  • The input array is non-empty and contains at least one element.
Live Compiler
Loading...
Test Cases & Output
🔒 Sign up to run your code

🚀 Practice this problem

Run code, get AI hints & track streak

Sign Up Free