Print uncommon elements from two sorted arrays | JavaScript program to find uncommon elements of two sorted arrays ; If not common , prlet smaller ; Skip common element ; prleting remaining elements ; Driver Code
function prletUncommon ( arr1 , arr2 , n1 , n2 ) { let i = 0 , j = 0 , k = 0 ; while ( i < n1 && j < n2 ) { if ( arr1 [ i ] < arr2 [ j ] ) { document . write ( arr1 [ i ] + " " ) ; i ++ ; k ++ ; } else if ( arr2 [ j ] < arr1 [ i ] ) { document . write ( arr2 [ j ] + " " ) ; k ++ ; j ++ ; } else { i ++ ; j ++ ; } } while ( i < n1 ) { document . write ( arr1 [ i ] + " " ) ; i ++ ; k ++ ; } while ( j < n2 ) { document . write ( arr2 [ j ] + " " ) ; j ++ ; k ++ ; } } let arr1 = [ 10 , 20 , 30 ] ; let arr2 = [ 20 , 25 , 30 , 40 , 50 ] ; let n1 = arr1 . length ; let n2 = arr2 . length ; prletUncommon ( arr1 , arr2 , n1 , n2 ) ;