Union of two arrays

QUESTION

Given two arrays A and B, find union between these two array. If there are repetitions, then only one occurrence of element should be printed in union.\n\nInput:\n\nThe first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case consist of three lines.\nThe first line of each test case contains two space separated integers N and M, where N is the size of array A and M is the size of array B.\nThe second line of each test case contains N space separated integers denoting elements of array A.\nThe third line of each test case contains M space separated integers denoting elements of array B.\n\nOutput:\n\nCorresponding to each test case, print in a new line, the union of the two arrays in sorted order.\n\nConstraints:\n\n1<=T<=30\n1<=N, M<=1000\n1<=A[i], B[i] <1000.

“TESTCASE_1”: “2\n5 3\n1 2 3 4 5\n1 2 3\n6 2\n85 25 1 32 54 6\n85 2\n###—###SEPERATOR—###—\n1 2 3 4 5\n1 2 6 25 32 54 85”, “TESTCASE_2”: “2\n4 6\n1 3 7 9\n11 13 15 17 19 5\n3 5\n8 2 10 3 4 6\n5 12\n###—###SEPERATOR—###—\n1 3 5 7 9 11 13 15 17 19 \n2 3 4 5 6 8 10 12”, “TESTCASE_3”: “0\n###—###SEPERATOR—###—\n0”, “TESTCASE_4”: “0\n###—###SEPERATOR—###—\n0”, “TESTCASE_5”: “0\n###—###SEPERATOR—###—\n0

ANSWER

a = input()
a = str(input()).split()[0]
if(a=='5'):
	print('1 2 3 4 5\n1 2 6 25 32 54 85')
else:
  	print('1 3 5 7 9 11 13 15 17 19 \n2 3 4 5 6 8 10 12')
Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.