Practice Maximum Sum Obtained of Any Permutation
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
We have an array of integers, nums, and an array of requests where requests[i] = [starti, endi]. The ith request asks for the sum of nums[starti] + nums[starti + 1] + ... + nums[endi - 1] + nums[endi]. Both starti and endi are 0-indexed. Return the maximum total sum of all requests among all permutations of nums. Since the answer may be too large, return it modulo 10^9 + 7.
Source: Maximum Sum Obtained of Any Permutation on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
nums = [1,2,3,4,5], requests = [[1,3],[0,1]]
19
# Example 2
nums = [1,2,3,4,5,6], requests = [[0,1]]
11
# Example 3
nums = [1,2,3,4,5,10], requests = [[0,2],[1,3],[1,1]]
47
Constraints
Related LeetCode Problems
Practice more problems similar to Maximum Sum Obtained of Any Permutation.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.