Three vault terminals in a secure facility each keep an independent access log for a single day. Every time a technician badges in, the terminal appends that access code to its own log, so each terminal's log lists codes in strictly increasing numeric order with no repeats (a code used earlier in the day is numerically smaller than one used later). Security wants to know exactly which access codes were presented at all three terminals on that day, listed from smallest to largest.
Print the access codes that appear in all three logs, in increasing order, separated by single spaces on one line. If no code appears in all three logs, print an empty line.
Example 1
Input
4 1 2 3 5 5 1 2 5 7 9 5 1 3 4 5 8
Expected
1 5
Explanation
Terminal A used {1,2,3,5}, B used {1,2,5,7,9}, C used {1,3,4,5,8}. The codes present in all three logs are 1 and 5, so the output is "1 5".
Example 2
Input
3 1 2 3 3 4 5 6 3 1 2 3
Expected
(empty)Explanation
Terminal B's log {4,5,6} shares nothing with A's or C's log {1,2,3}, so no code was used at all three terminals and the output is an empty line.
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 →