#Given two sorted arrays ,Print the elements in the union and intersection of these arrays #Time-complexity:O(n+m)(n=length of array1 and m=length of array2),Auxiliary-space: O(1) # Method for finding Union def union(a,b) len1=a.length len2=b.length ctr1=0 ctr2=0 puts "Union of the gives arrays:" while (ctr1 [1, 2, 3, 4] end def intersection(a,b) print a & b # intersection([1,2,3],[2,3,4]) => [2, 3] end