Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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. array size
Output Format
Output should print 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 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
Sample Output
Explanation
Union of U is since are already present in first list, only needs to be added at the end. Intersection common elements of both the lists are and Except even values in first list U odd values in second list is found by U in python code
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started