that returns a string made of digits for which the following calculate function returns…
- User
that returns a string made of digits for which the following calculate function returns the highest possible value:
int calculate(string &S) {
int length S.length();
if (length > 100) {
return 0;
}
vector count(100);
for (int i = 0; i < length 1; i++) {
int num stoi(S.substr(i, 2));
count [num] = 1;
}
return accumulate(count.begin(), count.end(), 0);
}
Scoring
Your score depends on the returned value by the function calculate (greater returned value, more points). Scoring table:Scoring
Your score depends on the returned value by the function calculate (greater returned value, more points). Scoring table:
returned value |
score
= 59
50
= 64
55
= 69
60
= 74
65
= 79
70
= 84
75
= 89
80
= 94
90
= 99
100
For example, if your function returns 95, your score is 90.
In your solution, focus on correctness. The performance of your solution will not be the focus of the assessment.
- Assistant