Back to problems

Sum of Elements Between Two Numbers

Algorithm · Meta · Easy

You are given an unordered array of integers along with two integers, S and E. Find the total of every array value that lies from S through E, including both endpoints. Example: Input: A = [6, 2, 8, 3, 7, 1, 4], S = 3, E = 7 Output: 20 Explanation: The values 6, 3, 7, and 4 fall inside the inclusive interval [3, 7]; together, they add up to 20. Example Explanation: The values 5, 6, and 3 fall inside the inclusive interval [3, 6]; together, they add up to 14.

Checking your access…