
If A = [2, 5, 7, 4, 9], then P = 2*Q can hold true for P = 4 and Q = 2. Which are at the 0-th index and 3rd index respectively.
The first line contains a single integer ‘T’, denoting the number of test cases.
The first line of each test case contains a single integer ‘N’ denoting the number of integers in the array.
The second line of each test case contains ‘N’ space-separated integers that make ‘A’.
For each test case, print “True”, if there exist two integers in the array as described in the problem statement. Otherwise, print “False”.
Print the output of each test case in a separate line.
You don’t need to print anything. It has already been taken care of. Just implement the given function.
1 <= T <= 10
1 <= N <= 10^5
-10^9 <= A[i] <= 10^9
Where A[i] is the integer at index ‘i’.
Time limit: 1 sec
The simple idea is that for every integer in ‘A’, traverse the complete array and check if there exists an integer that is double of it. If for any integer, it double exists, we will return true, otherwise false.
Below are the steps:
We can solve this problem by using a hash map. We will initialize a map 'M' that maps from integer to integer where key denotes the integer present in the array and value at that index denotes the number of times that integer occurs in the array.
Below are the steps: