[Solved] Competitive programming: “Time exceeded error”
Calculate the cumulative sum of the array and store it in another one, that is to say, accumulated[i] = sum of numbers of the array up to ith index. This can be computed in O(n). Then for a query, the answer will be accumulated[r] – accumulated[l]. This is O(1) solved Competitive programming: “Time exceeded error”