@@ -0,0 +1,1103 @@
+package leetcode;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.Collections;%0Aimport java.util.List;%0A%0A/**%0A * https://leetcode.com/problems/range-sum-of-sorted-subarray-sums/%0A */%0Apublic class Problem1508 %7B%0A    public int rangeSum(int%5B%5D nums, int n, int left, int right) %7B%0A        List%3CInteger%3E list = new ArrayList%3C%3E();%0A        for (int i = 0; i %3C nums.length; i++) %7B%0A            int sum = nums%5Bi%5D;%0A            list.add(sum);%0A            for (int j = i + 1; j %3C nums.length; j++) %7B%0A                sum += nums%5Bj%5D;%0A                list.add(sum);%0A            %7D%0A        %7D%0A        Collections.sort(list);%0A        long answer = 0;%0A        for (int i = left - 1; i %3C right; i++) %7B%0A            answer += list.get(i) %25 1_000_000_007;%0A        %7D%0A        return (int) answer;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem1508 prob = new Problem1508();%0A        System.out.println(prob.rangeSum(new int%5B%5D%7B1,2,3,4%7D, 4, 1, 5)); // 13%0A        System.out.println(prob.rangeSum(new int%5B%5D%7B1,2,3,4%7D, 4, 3, 4)); // 6%0A        System.out.println(prob.rangeSum(new int%5B%5D%7B1,2,3,4%7D, 4, 1, 10)); // 50%0A    %7D%0A%7D%0A

Update problem 1508