human
Union and Intersection of two sorted arrays | Python3 program to find union of two sorted arrays ( Handling Duplicates ).
Taking max element present in either array.
Finding elements from 1 st array ( non duplicates only ) . Using another array for storing union elements of both arrays Assuming max element present in array is not more than 10 ^ 7.
First element is always present in final answer.
Incrementing the First element ' s ▁ count ▁ ▁ in ▁ it ' s corresponding index in newtable.
Starting traversing the first array from 1 st index till last.
Checking whether current element is not equal to it 's previous element.
Finding only non common elements from 2 nd array.
By checking whether it 's already  present in newtable or not.
Driver Code"
Solution in Python:

What is a code to union and Intersection of two sorted arrays and the other steps required?
assistant
#Here is code to union and Intersection of two sorted arrays and the other steps required.
 def UnionArray ( arr1 , arr2 ) :
	m = arr1 [ - 1 ]
	n = arr2 [ - 1 ]
	ans = 0
	if m > n :
		ans = m
	else :
		ans = n
	newtable = [ 0 ] * ( ans + 1 )
	print ( arr1 [ 0 ] , end = " ▁ " )
	newtable [ arr1 [ 0 ] ] += 1
	for i in range ( 1 , len ( arr1 ) ) :
		if arr1 [ i ] != arr1 [ i - 1 ] :
			print ( arr1 [ i ] , end = " ▁ " )
			newtable [ arr1 [ i ] ] += 1
	for j in range ( 0 , len ( arr2 ) ) :
		if newtable [ arr2 [ j ] ] == 0 :
			print ( arr2 [ j ] , end = " ▁ " )
			newtable [ arr2 [ j ] ] += 1
if __name__ == " _ _ main _ _ " :
	arr1 = [ 1 , 2 , 2 , 2 , 3 ]
	arr2 = [ 2 , 3 , 4 , 5 ]
	UnionArray ( arr1 , arr2 )