You are given two sorted arrays that contain only integers. Your task is to find a way to merge them into a single one, sorted in **ascending order**. Complete the function `mergeArrays(arr1, arr2)`, where `arr1` and `arr2` are the original sorted arrays.

You don't need to worry about validation, since `arr1` and `arr2` must be arrays with 0 or more Integers. If both `arr1` and `arr2` are empty, then just return an empty array.

**Note:** `arr1` and `arr2` may be sorted in different orders. Also `arr1` and `arr2` may have same integers. Remove duplicated in the returned result.

## Examples

Happy coding!

Difficulty: introductory

Starter code:

def merge_arrays(arr1, arr2):
	

Solutions:
def merge_arrays(arr1, arr2):
    return sorted(set(arr1+arr2))

merge_arrays = lambda a, b: sorted(list(set(a + b)))

merge_arrays = lambda a1, a2: sorted(set(a1+a2))

def merge_arrays(arr1, arr2):
  for arr in (arr1, arr2):
    if arr[0] > arr[-1]:
      arr.reverse()
  res = []
  i = 0
  k = 0
  while not(i >= len(arr1) and k >= len(arr2)):
    left = arr1[i] if i < len(arr1) else float("inf")
    right = arr2[k] if k < len(arr2) else float("inf")
    res_last = res[-1] if res else None
    if left <= right:
      res_last != left and res.append(left)
      i += 1
    else:
      res_last != right and res.append(right)
      k += 1
  return res


def merge_arrays(arr1, arr2):
    return sorted(set(arr1).union(set(arr2)))

def merge_arrays(a,b):return(sorted(set(a+b)))

merge_arrays = lambda arr1, arr2: sorted(set(arr1 + arr2))

def merge_arrays(arr1, arr2):
    return sorted(list(set(arr1 + arr2)))

def merge_arrays(a1, a2):
    return sorted(list(set(a1 + a2)))

def merge_arrays(arr1, arr2):
    return sorted(set(arr1) | set(arr2))

from typing import List

def merge_arrays(arr1: List[int], arr2: List[int]) -> List[int]:
    """ Merge two sorted arrays into one and return it. """
    return sorted(set(arr1 + arr2))

def merge_arrays(arr1, arr2):
    arr3 = arr1 + arr2
    arr4 = sorted(arr3)
    
    uniqueList = []
    
    for i in arr4:
        if i not in uniqueList:
            uniqueList.append(i)
    return uniqueList

def merge_arrays(arr1, arr2):
    arr1 = [arr1, arr1[::-1]][arr1[0] < arr1[-1]]
    arr2 = [arr2, arr2[::-1]][arr2[0] < arr2[-1]]
    
    res = len(arr1) + len(arr2)
    new = []
    
    while len(new) < res:
        if arr1 and arr2:
            if arr1[-1] < arr2[-1]:
                item = arr1.pop()
            else:
                item = arr2.pop()
        elif arr1:            
            item = arr1.pop()
        elif arr2:
            item = arr2.pop()
        else:
            break

        if item not in new:
            new.append(item)
    return new

from heapq import merge
def merge_arrays(arr1, arr2):
    return sorted(set(merge(arr1, arr2)))

def merge_arrays(arr1, arr2):
    b=[]
    a=arr1+arr2
    [b.append(i) for i in a if i not in b] 
    b.sort()
    return b

def make_desc_order(arr):
    return arr[::-1] if arr and arr[0] < arr[-1] else arr

def merge_arrays_gen(*args):
    arr1, arr2 = (make_desc_order(arr) for arr in args)
    while arr1 or arr2:
        yield arr1.pop() if not arr2 or (arr1 and arr1[-1] < arr2[-1]) else arr2.pop()

merge_arrays = lambda *args: list(dict.fromkeys(merge_arrays_gen(*args)))  # Python 3.6+ 

def make_desc_order(arr):
    return arr[::-1] if arr and arr[0] < arr[-1] else arr

def merge_arrays_gen(*args):
    arr1, arr2 = (make_desc_order(arr) for arr in args)    
    while arr1 or arr2:
        if arr1 and arr2:
            yield arr1.pop() if arr1[-1] < arr2[-1] else arr2.pop()
        elif arr1:            
            yield arr1.pop()
        else:
            yield arr2.pop()

merge_arrays = lambda *args: list(dict.fromkeys(merge_arrays_gen(*args)))

merge_arrays=lambda a,b:sorted(set(a+b))

def merge_arrays(arr1, arr2):
    arr = []
    for el in arr1:
        if el not in arr:
            arr.append(el)
    for el in arr2:
        if el not in arr:
            arr.append(el)
    return sorted(arr)

def merge_arrays(arr1, arr2):
    arr1 = arr1+arr2
    res = []
    for i in arr1: 
        if i not in res: 
            res.append(i)
    return sorted(res)

def merge_arrays(arr1, arr2):
    x = arr1
    y = []
    for i in range(len(arr2)):
        x.append(arr2[i])
        
    for j in range(len(x)):
        if x[j] in y:
            y = y
        else:
            y.append(x[j])
    return sorted(y)


def merge_arrays(arr1, arr2):
    l=arr1+arr2
    l.sort()
    l1=[]
    for i in l:
        if(i not in l1):
            l1.append(i)
    return l1

def merge_arrays(arr1, arr2):
    return sorted(list(set(arr1 + arr2))) if arr1 or arr2 else []

def merge_arrays(a1, a2):
    return list(dict.fromkeys(sorted(a1+a2)))

def merge_arrays(arr1, arr2):
    arr1  = arr1 + arr2
    arr1 = sorted(arr1)
    a = arr1[0]
    arr = [arr1[0]]
    for x in range(1, len(arr1)):
        if arr1[x] != a:
            a = arr1[x]
            arr.append(arr1[x])
    return arr

def merge_arrays(arr1, arr2):
    arr = set(arr1 + arr2)
    return list(sorted(arr))

def merge_arrays(arr1, arr2):
    final_list = []
    for y in arr1:
        if y not in final_list:
            final_list.append(y)
    for x in arr2:
        if x not in final_list:
            final_list.append(x)
    return sorted(final_list)

def merge_arrays(arr1, arr2):
    arr = []
    for el in arr2:
        if el not in arr:
            arr.append(el)
    for el in arr1:
        if el not in arr:
            arr.append(el)
    
    return sorted(arr)


def merge_arrays(arr1, arr2):
    arr3=[]
    arr1=list(set(arr1))
    arr2=list(set(arr2))
    arr1.sort()
    arr2.sort()
    while len(arr1)>0 and len(arr2)>0:
        if arr1[0]<arr2[0]:
            arr3.append(arr1[0])
            del arr1[0]
        elif arr1[0]>arr2[0]:
            arr3.append(arr2[0])
            del arr2[0]
        else:
            arr3.append(arr1[0])
            del arr1[0]
            del arr2[0]
    return arr3+arr2 if len(arr1)==0 else arr3+arr1

def merge_arrays(arr1, arr2):
    ans=[]
    for x in arr1:
        if x not in ans:
            ans.append(x)
    for x in arr2:
        if x not in ans:
            ans.append(x)
    return sorted(ans)

def merge_arrays(arr1, arr2):
    return sorted(list(set(arr1 + arr2)))


'''You are given two sorted arrays that contain only integers. 
Your task is to find a way to merge them into a single one, 
sorted in ascending order. '''

def merge_arrays(arr1, arr2):
    noice = list(set(arr1+arr2))
    noice.sort()
    return noice

def merge_arrays(arr1, arr2):
    return sorted(list(set([*arr1, *arr2])))

def merge_arrays(arr1, arr2):
    ans=arr1+arr2
    ans= list(set(ans))
    ans.sort()
    return ans


def merge_arrays(arr1, arr2):
    res = []
    for num in arr1:
        if num not in res:
            res.append(num)
    for num in arr2:
        if num not in res:
            res.append(num)
    res.sort()
    return res

def merge_arrays(a, b):
    joined = a+b
    noDupes = []
    for x in joined:
        if x not in noDupes:
            noDupes.append(x)
    noDupes.sort()
    return noDupes
#---end function


def merge_arrays(arr1, arr2):
    a = set(arr1).union(set(arr2))
    b = list(a)
    b.sort()
    return b

def merge_arrays(arr1, arr2):
    print(arr1 + arr2)
    res = list(arr1 + arr2)
    res = sorted(set(res))
    return res

def merge_arrays(arr1, arr2):
    arr = []
    for i in arr1:
        if i not in arr:
            arr.append(i)
    for i in arr2:
        if i not in arr:
            arr.append(i)
    return sorted(arr)

def merge_arrays(a, b):
    return sorted(list(dict.fromkeys(a+b)))

def merge_arrays(arr1, arr2):
    arr1 = sorted(arr1)
    arr2 = sorted(arr2)
    i,j = 0,0
    result = []
    while True:
        if i == len(arr1):
            result.extend(arr2[j:])
            break
        elif j == len(arr2):
            result.extend(arr1[i:])
            break
        elif arr1[i] < arr2[j]:
            result.append(arr1[i])
            i += 1
        else:
            result.append(arr2[j])
            j += 1
    unique = []
    for num in result:
        if num not in unique:
            unique.append(num)
    return unique

def merge_arrays(arr1, arr2):
    my_List = arr1 + arr2
    a = list(set(my_List))
    return sorted(a)

def merge_arrays(arr1, arr2):
    final = []
    for el1 in arr1:
        if not el1 in final:
            final.append(el1)
    for el2 in arr2:
        if not el2 in final:
            final.append(el2)
    return sorted(final)

def merge_arrays(arr1, arr2):
    a=[]
    a=list(set(arr1+arr2))
    return sorted(a)

def merge_arrays(arr1, arr2):
    lista = []
    a  = sorted(arr1) + sorted(arr2)
    a.sort()
    for i in a:
        if i not in lista:
            lista.append(i)
    return lista
    


def merge_arrays(arr1, arr2):
    result = list(set().union(arr1, arr2))
    result.sort()
    return result

def merge_arrays(arr1, arr2):
    a = set(arr1).union(arr2)
    return sorted(list(a))

def merge_arrays(arr1, arr2):
    arr1.sort()
    arr2.sort()
    arr=arr1+arr2
    u=[]
    for a in arr:
        if a not in u:
            u.append(a)
    u.sort()
    return u

def merge_arrays(a,b):
    i=0
    x=[]
    while len(a)>i:
        if a[i] not in x:
            x.append(a[i])
        i+=1
            
    i=0
    while len(b)>i:
        if b[i] not in x:
            x.append(b[i])
        i+=1
    return sorted(x)

def merge_arrays(arr1, arr2):
    l=[]
    for x in arr1:
        l.append(x)
    for x in arr2:
        l.append(x)
    return sorted(list(set(l)))

def merge_arrays(arr1, arr2):
    # Merge arrays whithout duplicates
    arr = []
    for i in range(len(arr1)):
        if arr1[i] not in arr:
            arr.append(arr1[i])
    for i in range(len(arr2)):
        if arr2[i] not in arr:
            arr.append(arr2[i])
    # Selection sort arrays
    for i in range(len(arr)):
        m = min(arr[i:])
        index = arr.index(m)
        
        temp = arr[i]
        arr[i] = m
        arr[index] = temp
    return arr
            


def merge_arrays(arr1, arr2):
    arr1.extend(arr2)
    res=list(set(arr1))
    res.sort()
    return res

def merge_arrays(arr1, arr2):
    lst=list()
    for i in arr2:
        if i not in lst:
            lst.append(i)
    for i in arr1:
        if i not in lst:
            lst.append(i)
    return sorted(lst)

def merge_arrays(arr1, arr2):
    merged = arr1 + arr2
    a = sorted(merged)
    res = [] 
    [res.append(x) for x in a if x not in res] 
    return res

def merge_arrays(arr1, arr2):
    ls = list(set(arr1 + arr2))
    ls.sort()
    return ls

def merge_arrays(arr1, arr2):
    merge = set(arr1 + arr2)
    return sorted(list(merge))

def merge_arrays(*arr):
    return sorted(set(sum(arr, [])))

def merge_arrays(x, y):
    res = []
    while True:
        if len(x) == 0:
            res.extend(y)
            break
        if len(y) == 0:
            res.extend(x)
            break
        first, second = x[0], y[0]
        if first < second:
            res.append(first)
            x.pop(0)
        else:
            res.append(second)
            y.pop(0)
    return sorted(set(res))

def merge_arrays(arr1, arr2):
    for x in arr2:
        arr1.append(x)
    a=set(arr1)
    b=list(a)
    b.sort()
    return b

def merge_arrays(arr1, arr2):
    merge=list(set(arr1).union(set(arr2)))
    merge.sort()
    return merge

def merge_arrays(arr1, arr2):
    temp = arr1 + arr2
    res = [] 
    for i in temp: 
        if i not in res: 
            res.append(i)
    res.sort()
    return res

def merge_arrays(a1, a2):
    a = set(a1)
    a.update(a2) 
    return sorted(a)

def merge_arrays(arr1, arr2):
    ar = arr1 + arr2
    arr = []
    for c in ar:
        if c not in arr:
            arr.append(c)
    arr.sort()  
    return arr

def merge_arrays(arr1, arr2):
    res = (arr1 + arr2)
    res.sort()
    res = list(dict.fromkeys(res))
    return res

def merge_arrays(arr1, arr2):
    emptylist = []
    for eachnumber in arr1:
        if eachnumber in emptylist:
            continue
        else:
            emptylist.append(eachnumber)
    for eachnumber in arr2:
        if eachnumber in emptylist:
            continue
        else:
            emptylist.append(eachnumber)
    emptylist.sort()
    return emptylist

def merge_arrays(arr1, arr2):
    res = []
    for i in arr1 :
        if i not in res :
            res.append(i)
    for i in arr2 :
        if i not in res :
            res.append(i)
    res.sort()
    return res

def merge_arrays(arr1, arr2):
    sort_1 = sorted(list(dict.fromkeys(arr1)))
    sort_2 = sorted(list(dict.fromkeys(arr2)))
    one_index , two_index = 0,0
    result = []
    
    while one_index < len(sort_1) and two_index < len(sort_2):
        if sort_1[one_index] == sort_2[two_index]:
            result.append(sort_1[one_index])
            one_index+=1
            two_index+=1
        elif sort_1[one_index] < sort_2[two_index]:
            result.append(sort_1[one_index])
            one_index+=1
        elif sort_1[one_index] > sort_2[two_index]:
            result.append(sort_2[two_index])
            two_index+=1
    
    result.extend(sort_1[one_index:])
    result.extend(sort_2[two_index:])
                  
    return result

def merge_arrays(arr1, arr2):
    newarr=arr1+arr2
    ls=[]
    for i in newarr:
        if i in ls:
            continue
        ls.append(i)
    ls.sort()
    return ls

def merge_arrays(a1, a2):
    res = a1 + a2
    res = set(res)
    res = list(res)
    return sorted(res)
            


def merge_arrays(arr1, arr2):
    final_list=arr1+arr2
    return sorted(set(final_list))

def merge_arrays(arr1, arr2):
    """Merge Sort"""
    return(sorted(list(set(arr1+arr2))))

def merge_arrays(arr1, arr2):
    if arr1 and arr2:
        temp_arr = arr1 + arr2
        temp_arr.sort()
        final_arr = list(dict.fromkeys(temp_arr))
    return final_arr

def merge_arrays(arr1, arr2):
    for i in arr1:
        arr2.append(i)
    arr2.sort()
    a = list(dict.fromkeys(arr2))
    return a

def merge_arrays(arr1, arr2):
    ar = arr1+arr2
    ar = list(set(ar))
    ar.sort()
    
    return list(ar)

def merge_arrays(arr1, arr2):
    return sorted(set(arr1+arr2))
    #pass


def merge_arrays(arr1, arr2):

    arr3 = sorted(arr1+arr2)

    for i in range(len(arr3)):
        for j in range(0,len(arr3) - 1 - i):
            if arr3[i] == arr3[i+1]:
                del arr3[i]
            else:
                continue
    return arr3

def merge_arrays(arr1, arr2):
    if(arr1==[] and arr2==[]):
        return([])
    else:
        s=[*arr1,*arr2]
        t=list(set(s))
        t.sort()
        return(t)

def merge_arrays(arr1, arr2):
        lista = arr1 + arr2
        return list(sorted(set(lista)))

def merge_arrays(arr1, arr2):
    mylist = sorted(arr1 + arr2)
    mylist = list(dict.fromkeys(mylist))
    return (mylist)

def merge_arrays(arr1, arr2):
    x=[]
    for i in arr1:
        x.append(i)
    for j in arr2:
        x.append(j)
    return sorted(list(set(x)))

def merge_arrays(arr1, arr2):
    arr1.extend(arr2)
    arr1=list(set(arr1))
    return sorted(arr1)

def merge_arrays(arr1, arr2):
    unique = set(arr1)
    unique.update(arr2)
    return sorted(list(unique))

def merge_arrays(arr1, arr2):
    arr1.extend(arr2)
    arr1.sort()
    result = []
    for i in arr1:
        if i not in result:
            result.append(i)
    return result

def merge_arrays(arr1, arr2):
    if arr1 == [] and arr2 == []:
        return []
    salida = arr1+arr2
    return sorted(set(salida))


def merge_arrays(arr1, arr2):
    arr1.sort()
    arr2.sort()
    c=[]
    for i in arr1:
        c.append(i)
    for i in arr2:
        c.append(i)
    from collections import OrderedDict
    u=list(OrderedDict.fromkeys(c))
    u.sort()
    return u

def merge_arrays(arr1, arr2):
    temp = list(set(arr1 + arr2))
    return sorted(temp)

def merge_arrays(arr1, arr2):
    concat_set = list(set(arr1 + arr2))
    concat_set.sort()
    return concat_set

def merge_arrays(arr1, arr2):
    if arr1 == [] and arr2 == []:
        return []
    return sorted(list(set(arr1 + arr2)))

def merge_arrays(arr1, arr2):
    list=sorted(arr1+arr2)
    New_list=[]
    for x in list:
        if x not in New_list:
            New_list.append(x)
    return New_list

def merge_arrays(arr1, arr2):
    new = sorted(arr1+arr2)
    return list(dict.fromkeys(new))

def merge_arrays(arr1, arr2):
  arr1=sorted(arr1)
  arr2=sorted(arr2)
  i=0
  j=0
  sol=[]
  if len(arr1)+len(arr2)==0:
    return []
  for h in range(len(arr1)+len(arr2)):
    if j==len(arr2):
      sol.append(arr1[i])
      i += 1
    elif i==len(arr1):
      sol.append(arr2[j])
      j += 1
    elif arr1[i]<=arr2[j]:
      sol.append(arr1[i])
      i += 1
    elif arr1[i]>arr2[j]:
      sol.append(arr2[j])
      j += 1
  return sorted(set(sol), key = sol.index)

def merge_arrays(arr1, arr2):
  a = arr1+arr2
  # print(a)
  a.sort()
  mylist = list(dict.fromkeys(a))
  return mylist

def merge_arrays(arr1, arr2):
    
    mylist1 = arr1 + arr2
    
    return sorted(set(mylist1))
    



def merge_arrays(arr1, arr2):
    arr3 = []
    for i in set(arr1):
        arr3.append(i)
    for j in set(arr2):
        if j not in arr1:
            arr3.append(j)
    return sorted(arr3)

def merge_arrays(arr1, arr2):
    x = arr1 + arr2
    return sorted([i for i in set(x)])

def merge_arrays(arr1, arr2):
    p= list(set(arr1).union(set(arr2)))
    for i in range(0, len(p)-1):
        for j in range(i, len(p)):
            if p[j]<p[i]:
                temp=p[i]
                p[i]=p[j]
                p[j]=temp
            else:
                pass
    return p

def merge_arrays(arr1, arr2):
    merged = []
    for number in arr1 + arr2:
        if number not in merged:
            merged.append(number)
    return sorted(merged)

def merge_arrays(arr1, arr2):
    #merge then sort
    arr = arr1+arr2
    empty = []
    for i in arr:
        if i not in empty:
            empty.append(i)
    return sorted(empty)


def merge_arrays(arr1, arr2):
    a = sorted(arr1+arr2)
    ant = a[0]
    for x in a[1:]:
        if x == ant:
            a.remove(x)
            ant = x
        else:
            ant = x
    return a

def merge_arrays(arr1, arr2):
    arr = arr1 + arr2
    arr3 = []
    for item in arr:
        if item not in arr3:
            arr3.append(item)
    return sorted(arr3)