Company: Ion_17nov
Difficulty: medium
Maximize Sum of Medians 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 one input: long findMaxMedianSum(int nums[]) The function should return a long integer denoting the maximum total sum of medians of these groups. Examples Example 1: Input: nums = [3, 2, 9, 1, 6, 4], n = 6 Output: 9 Explanation: To maximize the sum of medians, we can form two groups: Group 1: From [3, 2, 9, 1, 6, 4], we can select [2, 6, 9]. The median of this sorted group is 6. Group 2: From the remaining elements, we can select [1, 3, 4]. The median of this sorted group is 3. The maximum sum of medians is 6 + 3 = 9