Timer is Running

C++ Sets
Submissions: 3   Accuracy:

33.33%

  Difficulty: Basic   Marks: 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

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Vanshika
Author: vanshi_14


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.