← All problems
#47 Subarray Sum Medium

Implement a program that computes the sum of a subarray of 32-bit integers. You are given an input array input of length N, and two indices S and E. S and E are inclusive, 0-based start and end indices — compute the sum of input[S..E].

Implementation Requirements

Example 1:

Input: input = [1, 2, 1, 3, 4], S = 1, E = 3
Output: output = 6

Example 2:

Input: input = [1, 2, 3, 4], S = 0, E = 3
Output: output = 10

Constraints

Guided walkthrough coming soon. Below is the official starter signature in each language; the clickable line-by-line explanation hasn't been authored yet.
Problem text & starters from the official AlphaGPU/leetgpu-challenges. Solve it on leetgpu.com.