Company: ION Group_3nov
Difficulty: medium
Maximize Median Sum Problem Description Given an array of integers nums with n elements, we need to divide these elements into groups of exactly 3 elements each. Each element can belong to at most one group, and not all elements need to be used. For each valid group we form, we calculate its median value. Implement a function that finds the sum of all these median values after optimally grouping the elements to maximize this sum. The function findMaxMedianSum will take an integer array nums as input and should return a long integer denoting the maximum total sum of medians of these groups. Examples Example 1: Input: nums = [2,3,4,4] Output: 4 Explanation: Given nums = [2,3,4,4] , we can form at most one group of 3 elements. To maximize the median, we choose the group [3,4,4] (when sorted, it is [3,4,4] ), which has a median of 4 . Other possible groups like [2,3,4] (median 3 ) would result in a smaller sum. The maximum sum of medians is 4 . Example 2: Input: nums = [3,2,9,1,6,4] Output