Two arrays of integers a and b are given, both already sorted in non-decreasing order (possibly with repeated values within the same array). Construct, by merging, the array of their union: a sorted array containing each value that appears in a or in b exactly once (no duplicates).
The required algorithm is the classic two-pointer merge, in which, before adding a new value to the result, you check whether it is already equal to the last written value.