FastPrepFastPrep
Problem Brief

Find Doubles

INTERNOA

Given a list of N integers, not necessarily unique, find all elements of the list for which there exists exactly one element of the list which is twice that number. The integers range from 0 to 1000. The list has no more than 100,000 elements.

Your code should find the appropriate values and print them to STDOUT in sorted order.

1Example 1

Input
numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 8]
Output
[0, 1, 2, 3]
Explanation

8 is 4*2, but 8 is present twice, 0 is its own double, so it's part of the result.

2Example 2

Input
numbers = [7, 17, 11, 1, 23]
Output
[]
Explanation

Nothing is exactly twice another element.

3Example 3

Input
numbers = [1, 1, 2]
Output
[1, 1]
Explanation

1 and 1 both have their double 2 present, and 2 is present in the list only once.

public List<Integer> findDoubles(List<Integer> numbers) {
  // write your code here
}
Input

numbers

[1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 8]

Output

[0, 1, 2, 3]

Sign in to submit your solution.