<jupyter_start><jupyter_text>Range Sum of Sorted Subarray SumsGiven the array nums consisting of n positive integers. You computed the sum of all non-empty continous subarrays from the array and then sort them in non-decreasing order, creating a new array of `n * (n + 1) / 2` numbers.Return the sum of the numbers from index left to index right (indexed from 1), inclusive, in the new array. Since the answer can be a huge number return it modulo `10^9 + 7`.  解析题目来源:[LeetCode - Range Sum of Sorted Subarray Sums - 1508]此题没有多少套路，基本上按照描述的进行即可，要注意生成子串的时候，使用kadane算法，以减少时间复杂度<jupyter_code>def rangeSum(nums, n, left, right):
    sum_result = []
    for idx in range(0,len(nums)):
        cur = nums[idx]
        result = [cur]
        for child_idx in range(idx + 1,len(nums)):
            cur += nums[child_idx]
            result.append(cur)
        sum_result.append(result)
    sum_result = sorted([j for i in sum_result for j in i])
    return sum(sum_result[left - 1:right])%(10**9 + 7)
print(rangeSum([1,2,3,4],4,1,5))<jupyter_output>18
{'fraction_non_alphanumeric': 0.10182516810758886, 'fraction_numerical': 0.025936599423631124, 'mean_word_length': 3.7363636363636363, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '480682', 'license': 'MIT', 'n_tokens_mistral': 394, 'n_tokens_neox': 388, 'n_words': 120, 'path': 'Range-Sum-of-Sorted-Subarray-Sums.ipynb', 'repo_name': 'AllenTom/Algorithm', 'size': '1041'}