Difference of Two Sorted Arrays

Given two non-empty integer arrays a and b, each sorted in non-decreasing order, return the unique values that occur in a but do not occur in b. Return those…

Given two non-empty integer arrays `a` and `b`, each sorted in non-decreasing order, return the unique values that occur in `a` but do not occur in `b`. Return those values in increasing order.

- `1 <= a.length, b.length <= 10^5` - `-10^9 <= a[i], b[i] <= 10^9` - Both arrays are sorted in non-decreasing order. - The interactive visualizer accepts at most 10 values per array; longer valid inputs are execution-only.

Example 1: input a = [1,1,2,4,4,7], b = [1,3,4,4,6]; output [2,7]. The values 1 and 4 occur in both arrays, so only the unique first-only values remain.

Example 2: input a = [1,2,3], b = [1,1,2,2,3,3]; output []. Every value from the first array also occurs in the second array.

Category: Two Pointers. Topic: two-pointers. Difficulty: Easy. Patterns: two-pointers, sorting.