首页 > 解决方案 > 两组数组元素之和的最大乘积

问题描述

如果我们有一个数组。将数组分成两组的逻辑是什么,使得第 1 组的元素之和与第 2 组的元素之和的乘积可以是最大的。

Ex1-> arr[] = {9,16,5}
     Here we can have 2 groups with maximum product of sum as {16} and {5,9}
     Ans-> 16*(5+9) = 16*14 = 224

Ex2-> arr[] = {1,2,3,4,5}
      2 groups which can be formed which can give maximum product of sum is {1,2,5} and {3,4}
      Ans-> 8*7 = 56

标签: algorithmmath

解决方案


推荐阅读