Two course catalogs each tag their courses with lowercase keyword tags (letters, digits, and hyphens only). Given both tag lists, find the tags that appear in both catalogs.
Print the shared tags, each listed once, sorted in ascending lexicographic order, space-separated. If no tag is shared, print NONE.
Line 1: an integer n — the number of tags in catalog A.
Line 2: n space-separated tags.
Line 3: an integer m — the number of tags in catalog B.
Line 4: m space-separated tags.
The distinct shared tags, sorted ascending, space-separated on one line — or NONE if the two catalogs share no tag.
-).Example 1
Input
4 python java go rust 3 java rust c
Expected
java rust
Explanation
java and rust appear in both catalogs; python, go, and c each appear in only one, and are excluded. Sorted alphabetically: java rust.
Example 2
Input
2 apple banana 2 cherry date
Expected
NONE
Explanation
The two catalogs share no tag at all, so the output is 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 →