Prefix Sum Function

Programming Interview Medium 4 views
Back to Questions

Problem Description

Consider {x}. Write function build_prefix(arr) and answer sums fast.

Input Format

First line n q. Second line n integers. Next q lines l r.

Output Format

q lines sums.

Sample Test Case

Input:
5 3 1 2 3 4 5 1 3 2 4 4 5
Output:
6 9 9

Constraints

1

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev Next