Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Loop from i = 0 to arr.length, maintaining in a hashTable the array elements from [0, i - 1].
On each step of the loop check if we have seen the element <code>2 * arr[i]</code> so far.
Also check if we have seen <code>arr[i] / 2</code> in case <code>arr[i] % 2 == 0</code>.