java.lang.Object
g1301_1400.s1346_check_if_n_and_its_double_exist.Solution

public class Solution extends Object
1346 - Check If N and Its Double Exist.<p>Easy</p> <p>Given an array <code>arr</code> of integers, check if there exists two integers <code>N</code> and <code>M</code> such that <code>N</code> is the double of <code>M</code> ( i.e. <code>N = 2 * M</code>).</p> <p>More formally check if there exists two indices <code>i</code> and <code>j</code> such that :</p> <ul> <li><code>i != j</code></li> <li><code>0 <= i, j < arr.length</code></li> <li><code>arr[i] == 2 * arr[j]</code></li> </ul> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> arr = [10,2,5,3]</p> <p><strong>Output:</strong> true</p> <p><strong>Explanation:</strong> N <code>= 10</code> is the double of M <code>= 5</code>,that is, <code>10 = 2 * 5</code>.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> arr = [7,1,14,11]</p> <p><strong>Output:</strong> true</p> <p><strong>Explanation:</strong> N <code>= 14</code> is the double of M <code>= 7</code>,that is, <code>14 = 2 * 7</code>.</p> <p><strong>Example 3:</strong></p> <p><strong>Input:</strong> arr = [3,1,7,11]</p> <p><strong>Output:</strong> false</p> <p><strong>Explanation:</strong> In this case does not exist N and M, such that N = 2 * M.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>2 <= arr.length <= 500</code></li> <li><code>-10^3 <= arr[i] <= 10^3</code></li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • checkIfExist

      public boolean checkIfExist(int[] arr)