algorithm - 两组数组元素之和的最大乘积
问题描述
如果我们有一个数组。将数组分成两组的逻辑是什么,使得第 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
解决方案
推荐阅读
- android - Android 应用操作:语音/文本调用
- jenkins - 无法从 Jenkins 管道的当前阶段获取日志
- http - Adodb 连接到带有 https 地址的访问数据库
- c++ - 在字符串 C++ 中查找倒数第二个单词
- python - /srv/share/ykant3/pythia/vector_cache/wiki.en.bin 无法打开加载
- python - Python调度-如何每5分钟从HTML中提取数据
- javascript - 如何将 SortableJS 位置保存到对象?
- tableau-api - Tableau:空行的总和
- java - Maven 阴影插件 - 不要重新定位排除/可选范围依赖项
- javascript - 如果包含相同类型的类或标识符,则对重复的输入值求和