A regional weather service runs three independent Doppler radar stations that each scan the same airspace and log the integer IDs of storm cells they detect during a pass. A single station can occasionally log the same storm cell twice within its own list (a repeat ping), and that should not inflate its confidence — a station either detected a given storm cell during the pass or it did not. Meteorologists trust a storm cell as genuinely present only when it was independently detected by at least two of the three stations. Given the three stations' detection lists, report every storm-cell ID that meets this bar, in increasing order.
The input is a single stream of whitespace-separated integers:
na nb nc — the number of entries logged by station A, station B, and station C respectively.na integers — the IDs logged by station A.nb integers — the IDs logged by station B.nc integers — the IDs logged by station C.Print the distinct storm-cell IDs that were detected by at least two of the three stations, in strictly increasing order, separated by single spaces on one line. If no ID qualifies, print an empty line.
Example 1
Input
4 2 1 1 1 3 2 2 3 3
Expected
2 3
Explanation
Station A's deduplicated set is {1,2,3}, station B's is {2,3}, station C's is {3}. ID 2 appears in A and B (2 stations). ID 3 appears in A, B, and C (3 stations). ID 1 appears only in A. So the qualifying IDs, sorted, are 2 and 3.
Example 2
Input
3 3 1 1 2 2 4 3 3 5
Expected
(empty)Explanation
Station A's set is {1,2}, station B's set is {3,4}, station C's set is {5}. No ID appears in more than one station's set, so the output is empty.
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 →