CJCoding With Joseph
15free / daySign inCreate account

Count Newly Inserted Values

Write a function int insertAll(set<int>& s, const vector<int>& v) that inserts every element of v into s and returns how many of those insertions actually added a new element.

For example, if s starts as {5} and v is {1, 5, 2, 3, 1}, the function returns 3.

Do NOT write a main function.

Expected Output:

3
0

= newline. The output ends with a newline — print one after the last line.

Hints4 available
Topics:
STL ContainersSets
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.