call(back)
Algorithms & Data StructureseasySign in to star problems

Unique Values Across Two Arrays II

Given two arrays, return only the values that occur exactly once across both, in first-seen order: appearOnce(a, b).

appearOnce([1, 2, 2, 3], [3, 4])   // [1, 4]

Values are numbers and strings, and 1 and "1" are different values. Repeats within one array count too.

Hints

Hint 1

Count every value in a Map over both arrays, then keep the values whose count is 1. A Map keeps first-seen order.

Asked at