Hi,
I am just sharing my view on this, you have mentioned that it's complexity is O(mn), but it's not.
As Input to you as a query is Range of indices (Start Index, End Index)
So the sum you can get easily by
for(i = startIndex-1 ; i < EndIndex; i++)
{
sum = sum + arr[i];
}
Which is linear complexities O(N), where N = EndIndex - StartIndex, and in case of worst case N can be equal to number of element in the array.
Share your view on this.