Zepruv › Coding problems

Check If N and Its Double Exist

Easy · Array, Hash Table, Two Pointers, Binary Search, Sorting

Given an array arr of integers, check if there exist two indices i and j such that :

Example 1

Input: arr = [10,2,5,3]
Output: true

For i = 0 and j = 2, arr[i] == 10 == 2 * 5 == 2 * arr[j]

Example 2

Input: arr = [3,1,7,11]
Output: false

There is no i and j that satisfy the conditions.

Constraints

Starter code (python)

class Solution(object):
    def checkIfExist(self, arr):
        """
        :type arr: List[int]
        :rtype: bool
        """
        

Related problems

Previous: Jump Game V · Next: Find the Longest Substring Containing Vowels in Even Counts · All problems

Zepruv is a technical interview practice platform. Read any problem for free; sign in to run your code, submit and keep your progress.