Skip to content

Latest commit

 

History

History
24 lines (20 loc) · 566 Bytes

File metadata and controls

24 lines (20 loc) · 566 Bytes

Find Element In An Array

Easy


  1. You are given a number n, representing the size of array a.
  2. You are given n distinct numbers, representing elements of array a.
  3. You are given another number d.
  4. You are required to check if d number exists in the array a and at what index (0 based).
  5. If found print the index, otherwise print -1

Example 1:

Input:  6 15 30 40 4 11 9 40
Output:  2

Constraints:

1 <= n <= 10^7
-10^9 <= n1, n2 
.. n elements <= 10^9
-10^9 <= d <= 10^9