SumUnique
Rookie SRM 7 · 2021-11-25 · by erinn
Rookie SRM 7 · 2021-11-25 · by erinn · Brute Force
Problem Statement
Problem Statement
You are given a list of
Constraints
- values will contain between 1 and 50 elements, inclusive.
- Each element of values will be between 1 and 100, inclusive.
Examples
0)
{ 1, 2, 3, 4, 5 }
Returns: 15
The values are all unique, so we return 1 + 2 + 3 + 4 + 5 = 15.
1)
{ 1, 2, 3, 4, 3 }
Returns: 10
The value 3 is duplicated, so we only count it once. 1 + 2 + 3 + 4 = 10.
2)
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 }
Returns: 1
3)
{ 18, 22, 9, 1, 7, 18, 13, 49, 13, 9, 49, 49, 7 }
Returns: 119
4)
{ 1 }
Returns: 1
Submissions are judged against all 15 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Coding Area
Language: C++17 · define a public class SumUnique with a public method int getSum(vector<int> values) · 15 test cases · 2 s / 256 MB per case