Problem 217345 · easy · Phase 02 Linear Data Structures

In Exactly One List

sets · symmetric difference · ordering

Given integer lists a and b, return the values that appear in exactly one of the two lists. Output first the qualifying values from a (in order of first appearance in a), then the qualifying values from b (in order of first appearance in b). Each value appears once.

Examples

Input:  a = [1, 2, 2, 3], b = [3, 4, 1, 4]
Output: [2, 4]

Input:  a = [5, 6], b = [7, 5]
Output: [6, 7]

Constraints

  • 0 <= len(a), len(b) <= 10**5
  • Target complexity: O(n + m) time.

Goals

  • Combine two set differences
  • Follow a two-part ordering rule
Starting Python…