Question: Given two lists of numbers, perform the operations as defined below: UNION: Newly generated list should contain all the common elements and the remaining elements

Given two lists of numbers, perform the operations as defined below:
UNION: Newly generated list should contain all the common elements and the remaining elements which are not common. EXCEPT: Remove odd value elements from the first list and even value elements from the second list and returns the new list. INTERSECT: Returns the new list with elements that are present in both the lists.
Input Format
Rate This Challenge:
Two lines of integers, separated by space First line will be the elements of first array Second line will be the elements of second array
More
The inputs will be given as strings, you have to include logic to parse and convert them as integers.
Constraints
All integers are positive. 1<= array size <=100
Output Format
Output should print 3 lines. First line should be the Union of two arrays, space separated. Second line should be the intersection of two arrays. Third line should be the except of two arrays.
Output should print 3 lines. First line should be the Union of two arrays, space separated. Second line should be the intersection of two arrays. Third line should be the except of two arrays.
Sample Input 01253891758
Sample Output 0
125389715828175
Explanation 0
Union of {1,2,5,3,8,9} U (1,7,5,8} is {1,2,5,3,8,9,7} since 1,5,8 are already present in first list, only 7 needs to be added at the end. Intersection (common elements) of both the lists are 1,5 and 8. Except (even values in first list U odd values in second list) is found by {2,8}U(1,7,5).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!