Check If N and Its Double Exist
In this lab, you will be implementing a function called
checkIfExist that checks if there exist two indices
j in a given array
arr of integers that satisfy the following conditions:
i != j
0 <= i, j < arr.length
arr[i] == 2 * arr[j]
The function should return a boolean value as the result.
const arr = [10, 2, 5, 3]; checkIfExist(arr); // Output: true // Explanation: For i = 0 and j = 2, arr[i] == 10 == 2 * 5 == 2 * arr[j]
const arr = [3, 1, 7, 11]; checkIfExist(arr); // Output: false // Explanation: There is no i and j that satisfy the conditions.
2 <= arr.length <= 500
-103 <= arr[i] <= 103
In order to successfully pass the challenges, please make sure to follow the instructions as described in the challenges and make use of the ESM import/export wherever needed. The code you write will be evaluated using the evaluation script provided, and ensure that the length of the array
testlog matches the number of challenges specified in the lab.
Good luck, and happy coding!