Description
Solutions
Minimum Product Sum
π©βπ NEW GRADπRELATED PROBLEMS
Given an array of n
integers, arr[n]
, rearrange them so that the following equation is minimized.
Image of this equation is temporarily shown in the following π I will find a way to do this
Note: The equation uses 1-based indexing.
Function Description
Complete the function findMinimumSum
in the editor below.
findMinimumSum
has the following parameters:
int arr[n]
: the array to optimize
Returns
long: the minimum sum of products from the array
Example 1:

Input: arr = [1, 10, 2, 7, 10, 6, 6]
Output: 127
Explanation:One of the optimal rearrangements is
arr = [10, 1, 7, 6, 6, 2, 10]
, producing the result10 * 1 + 1 * 7 + 7 * 6 + 6 * 6 + 6 * 2 + 2 * 10 = 127
.
Constraints:
1 β€ n β€ 2 * 10^5
1 β€ arr[i] β€ 10^5

Related Problems
Testcase
Result
Case 1
input:
output: