Common Elements in Three Arrays
Easyjavapythonccppjavascript
Given three sorted arrays, find the values that occur in all three.
Input Format
The input contains three arrays, each given as its length on one line followed by that many space-separated integers on the next line: N, array A, M, array B, P, array C. Each array is sorted in non-decreasing order.
Output Format
Print the distinct common values in increasing order, separated by single spaces. If there are none, print an empty line.
Example 1
Input
6 1 5 10 20 40 80 5 6 7 20 80 100 7 3 4 15 20 30 70 80
Output
20 80
Explanation: Only 20 and 80 occur in all three arrays.
- 1 <= N, M, P <= 100000
- -1000000000 <= values <= 1000000000