Pure StorageOA #12
Find Doubles
Estimated EasyJudge-ready
Topics (AI-labelled)Hashing
You are given a list of integers. For each element x in the list, if exactly one element in the list equals 2x, include this x in the answer; the answer keeps repeated occurrences of x from the input and is output in ascending order. Twice 0 is still 0.
Input
The first line contains n; the second line contains n integers. The original upper limits are kept in full: 0≤n≤100000, 0≤value≤1000. The original problem gives no positive lower bound on the length, so this site explicitly allows the empty list n=0.
Output
Output all matching elements in ascending order, separated by spaces; if the answer is empty, output an empty line.
Example 1
Input:
11
1 2 3 4 5 6 7 8 9 0 8
Output:
0 1 2 3
Example 2
Input:
5
7 17 11 1 23
Output:
Example 3
Input:
3
1 1 2
Output:
1 1
Editorial
Loading solution…