Symmetric Difference of Two Sorted Arrays
Given two non-empty integer arrays a and b, each sorted in non-decreasing order, return their symmetric difference in increasing order. Include a value…
Given two non-empty integer arrays `a` and `b`, each sorted in non-decreasing order, return their symmetric difference in increasing order. Include a value exactly once when it appears in exactly one input; omit every value shared by both inputs.
- `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,2,3,4,5], b = [2,3,4,4,5,6]; output [1,6]. Values 2 through 5 occur in both arrays, so only 1 and 6 remain.
Example 2: input a = [1,1,2], b = [2,2,3]; output [1,3]. Repeated copies do not change whether a value occurs in an input.
Category: Two Pointers. Topic: two-pointers. Difficulty: Easy. Patterns: two-pointers, sorting.