Two backend systems, A and B, each maintain a list of customer IDs (integers; a system's own list may contain duplicates, which should be treated as a single membership). Find the customer IDs that belong to exactly one of the two systems (their symmetric difference).
Print these IDs sorted in ascending order, space-separated. If no such ID exists, print NONE.
Line 1: an integer n — size of system A's list.
Line 2: n space-separated integers — system A's customer IDs.
Line 3: an integer m — size of system B's list.
Line 4: m space-separated integers — system B's customer IDs.
The sorted, space-separated IDs that appear in exactly one of the two systems, or NONE if there are none.
Example 1
Input
4 1 2 3 4 3 3 4 5
Expected
1 2 5
Explanation
System A has {1,2,3,4} and system B has {3,4,5}. IDs 3 and 4 are in both (excluded); 1 and 2 (only in A) and 5 (only in B) remain. Sorted: 1 2 5.
Example 2
Input
2 7 8 2 7 8
Expected
NONE
Explanation
Both systems have exactly the same customers, so no ID belongs to only one system. Output NONE.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →