C++ Sets
Basic Accuracy: 51.73% Submissions: 29 Points: 1

Given two sets A and B of size N and M . Perform set operation i.e union, intersection and difference on sets using set_union, set_difference and set_intersection functions of STL.


Example 1:

Input: N = 4, M = 5
A = {1, 2, 3, 4}
B = {3, 4, 5, 6, 7}
Output:
1 2 3 4 5 6 7
1 2
3 4
Explaination: 
Union of two sets A (1 2 3 4) and 
B (3 4 5 6 7) is (1 2 3 4 5 6 7).
Difference A-B is 1 2.
The intersection is 3 4.


Your Task:
You do not need to read input or print anything. Your task is to complete the function setOperations() which takes set A and set B as input parameters and returns a list containing the three desired sets.


Expected Time Complexity: O(N + M)
Expected Auxiliary Space: O(N+M)


Constraints:
1 <= N, M <= 1000

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Output Window