Grazitti Interactive's analytics tooling receives an integer sequence and many requests for the total value within a contiguous index range. Given an array nums and a list of inclusive range queries, return the sum for every query efficiently.
Implement range_sum_queries(nums, queries). The parameter nums is a list of integers. Each query is a two-element list [left, right], where 0 <= left <= right < len(nums). Return a list of integers, where the result at position i is the sum of nums[left:right + 1] for queries[i].
Use preprocessing so that repeated queries do not require rescanning the array. Do not modify nums or queries.
def range_sum_queries(nums, queries):