Elements Only in the First Set
mediumQuestion 467Write a function set<int> difference(const set<int>& a, const set<int>& b) that returns a new set containing every value that is in a but not in b. Neither input set may be modified.
The test prints the returned set's elements in ascending order separated by single spaces, or the word empty if the returned set has no elements.
For example, with a = {1, 2, 3, 4} and b = {2, 4} the result is {1, 3}, printed as 1 3.
Do NOT write a main function.
Expected output
1 3 empty
= newline. The output ends with a newline, so print one after the last line.
Hints4 available
Sign in to use hintsTopics
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.