Description
Given an array arr, check if there exists two indices i and j such that i != j, arr[i] == 2 * arr[j].
Examples
Input:
arr = [10,2,5,3]Output:
trueExplanation:
arr[0] = 10 = 2 * arr[2]
Input:
arr = [10, 2, 5, 3]Output:
trueExplanation:
arr[0] = 10 = 2 * arr[2] (10 = 2*5), so a double exists.
Input:
arr = [7,1,14,11]Output:
trueExplanation:
arr[2] = 14 = 2 * arr[0] (since 14 = 2 * 7). The indices i=2 and j=0 are different and satisfy the condition.
Constraints
- •
2 ≤ arr.length ≤ 500