/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		int[] arr1 = { 1, 3, 9, 5 };
		int[] arr2 = { 7, 0, 5, 4, 3 };
		int arr1Len = arr1.length;
		int arr2Len = arr2.length;
		int[] both = new int[arr1Len+arr2Len];
		int[] result = new int[arr1Len+arr2Len];
		System.arraycopy(arr1, 0, both, 0, arr1Len);
		System.arraycopy(arr2, 0, both, arr1Len, arr2Len);
		
		//Array sort complexity O(n) < x < O(n lg n)
		Arrays.sort(both);
		
		//Sorted array duplication removal O(n)
		int counterUnique = 0;
		result[0] = both[0];
		for (int item : both) {
		  if(result[counterUnique] != item){
		    result[++counterUnique]=item;
		  }
		}
		
		//optional
		int[] rightSizeResult = Arrays.copyOf(result, counterUnique+1);
		System.out.println(Arrays.toString(rightSizeResult));
	}
}