Question: import java.util. * ; class UnionOfTwoArraysBasicDSA { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System
import java.util.;
class UnionOfTwoArraysBasicDSA
public static void mainString args
Scanner sc new ScannerSystemin;
int n scnextInt;
int m scnextInt;
List A new ArrayList;
List B new ArrayList;
for int i ; i n; i
AaddscnextInt;
for int i ; i m; i
BaddscnextInt;
List result unionOfTwoArraysA B;
for int i : result
System.out.printi ;
static List unionOfTwoArraysList A List B
Problem Description
You are given two arrays A and B of size n and m respectively. You need to find the resultant array of the union between these two arrays.
Elements are not necessarily distinct.
Note:Union of the two arrays can be defined as the set containing distinct elements from both the arrays. If there are repetitions, then only one occurrence of element should be printed in the union.
Resultant Array should be in sorted order
Input format
Line : Two integers n and m denoting the size of the array A and B
Line : An array of integers A separated by space.
Line : An array of integers B separated by space.
Output format
Return resultant list denoting the the union between these two arrays in sorted order.
Sample Input
Sample Output
Explanation
and are the elements which comes in the union set of both arrays.
Sample Input
Sample Output
Explanation
and are the elements which comes in the union set of both arrays.
Constraints
n m
Ai Bi please provide code
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
