|
1 | 1 | packagecom.fishercoder.solutions; |
2 | 2 |
|
3 | | -/** |
4 | | - * 1346. Check If N and Its Double Exist |
5 | | - * |
6 | | - * Given an array arr of integers, check if there exists two integers N and M such that N is the double of M ( i.e. N = 2 * M). |
7 | | - * |
8 | | - * More formally check if there exists two indices i and j such that : |
9 | | - * |
10 | | - * i != j |
11 | | - * 0 <= i, j < arr.length |
12 | | - * arr[i] == 2 * arr[j] |
13 | | - * |
14 | | - * Example 1: |
15 | | - * Input: arr = [10,2,5,3] |
16 | | - * Output: true |
17 | | - * Explanation: N = 10 is the double of M = 5,that is, 10 = 2 * 5. |
18 | | - * |
19 | | - * Example 2: |
20 | | - * Input: arr = [7,1,14,11] |
21 | | - * Output: true |
22 | | - * Explanation: N = 14 is the double of M = 7,that is, 14 = 2 * 7. |
23 | | - * |
24 | | - * Example 3: |
25 | | - * Input: arr = [3,1,7,11] |
26 | | - * Output: false |
27 | | - * Explanation: In this case does not exist N and M, such that N = 2 * M. |
28 | | - * |
29 | | - * Constraints: |
30 | | - * 2 <= arr.length <= 500 |
31 | | - * -10^3 <= arr[i] <= 10^3 |
32 | | - * */ |
33 | 3 | publicclass_1346 { |
34 | 4 | publicstaticclassSolution1 { |
35 | 5 | publicbooleancheckIfExist(int[]arr) { |
|