(This question is a variation of the LeetCode question 88. Merge Sorted Array. If you haven't completed that question yet, it is recommended to solve it first.)
Given two sorted integer arrays nums1 and nums2, merge them into one sorted array with every distinct value appearing exactly once, in ascending order.
Both nums1 and nums2 are guaranteed to be already sorted in non-decreasing order.
Constraints:
- 0 ≤
nums1.length,nums2.length≤ ≤nums1[i],nums2[i]≤
Example 1:
Input: nums1 = [1, 2, 2, 4, 7], nums2 = [2, 3, 4, 4, 5] Output: [1, 2, 3, 4, 5, 7] Explanation: Combining both arrays gives the values [1, 2, 2, 2, 3, 4, 4, 4, 5, 7]. Keeping only one copy of each distinct value in ascending order produces [1, 2, 3, 4, 5, 7].
Example 2:
Input: nums1 = [1, 1, 2, 2, 3, 5, 5], nums2 = [1, 2, 2, 4, 5, 5, 6] Output: [1, 2, 3, 4, 5, 6]
Example 3:
Input: nums1 = [1, 3, 5], nums2 = [2, 4, 6] Output: [1, 2, 3, 4, 5, 6]
