-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIntegration.cpp
More file actions
80 lines (70 loc) · 2.18 KB
/
Integration.cpp
File metadata and controls
80 lines (70 loc) · 2.18 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
int solution(vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> peaks;
vector<int> valleys
int max_profit;
//int max_blocks = 0;
//cout << A.size()/2 << endl;
for(int i = 3;i < (A.size()/2);i++)
{
if(((A.size()) % i) != 0)
{
continue;
}
//cout << "checking " << i << endl;
int peak = 0;
//check for peaks in each block
for(int j = 0;j < (A.size()/i);j++)
{
//check for peak in block k
for (vector<int>::const_iterator it=(A.begin() + j*i + 1); it!=(A.begin() + (j+1)*i); ++it)
{
if((*(it-1) < *it)&&(*it > *(it + 1)))
{
peak.push_back(*it);
}
}
//if(peak == //number of blocks)
}
}
for(int i = 3;i < (A.size()/2);i++)
{
if(((A.size()) % i) != 0)
{
continue;
}
//cout << "checking " << i << endl;
int valley = 0;
//check for peaks in each block
for(int j = 0;j < (A.size()/i);j++)
{
//check for valley in block k
for (vector<int>::const_iterator it=(A.begin() + j*i + 1); it!=(A.begin() + (j+1)*i); ++it)
{
if((*(it-1) > *it)&&(*it < *(it + 1)))
{
valley.push_back(*it);
}
}
//if(peak == //number of blocks)
}
}
for (std::vector<int>::const_iterator it = valleys.begin(); it != valleys.end(); ++it)
{
vector<int>::iterator it2;
it2 = find (A.begin(), A.end(), *it);
for (std::vector<int>::const_iterator it3 = peaks.begin(); it3 != peaks.end(); ++it3)
{
}
//cout << "valley " << *it << endl;
}
//return max_blocks;
}