-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMinimizeSumOfArrayArraySeries1.cpp
More file actions
62 lines (48 loc) · 1.34 KB
/
MinimizeSumOfArrayArraySeries1.cpp
File metadata and controls
62 lines (48 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include <string>
#include <iostream>
using namespace std;
int minSum(vector<int>passed)
{
int result = 0;
sort(passed.begin(), passed.end());
int g = passed.size();
for (int i = 0; i < g / 2; i++)
{
result += passed[g - 1 - i] * passed[i];
}
return result;
}
int main() {
cout << minSum({ 5, 4, 2, 3 });
return 0;
}
/*Description:
Introduction and Warm-up (Highly recommended)
Playing With Lists/Arrays Series
Task
Given an array of integers , Find the minimum sum which is obtained from summing each Two integers product .
Notes
Array/list will contain positives only .
Array/list will always have even size
Input >> Output Examples
minSum({5,4,2,3}) ==> return (22)
Explanation:
The minimum sum obtained from summing each two integers product , 5*2 + 3*4 = 22
minSum({12,6,10,26,3,24}) ==> return (342)
Explanation:
The minimum sum obtained from summing each two integers product , 26*3 + 24*6 + 12*10 = 342
minSum({9,2,8,7,5,4,0,6}) ==> return (74)
Explanation:
The minimum sum obtained from summing each two integers product , 9*0 + 8*2 +7*4 +6*5 = 74
Playing with Numbers Series
Playing With Lists/Arrays Series
For More Enjoyable Katas
ALL translations are welcomed
Enjoy Learning !!
Zizou
Fundamentals
Arrays*/