...

/

Solved Problem - Subarray Sum

Solved Problem - Subarray Sum

In this lesson, we'll see an effective way to compute sum of an subarray.

We'll cover the following...

Problem statement

Given an array, AA, of NN integers, answer QQ queries of the type (l,r)(l, r) - sum of the elements in the subarray A[l...r]A[l...r]. Print the sum for each query.

Input format

The first line contains two space-separated integers NN and QQ (1N,Q106)(1 \leq N,Q \leq 10^6).

The second line contains NN integers representing the array ...