Posts

Showing posts from December, 2017

Questions

Given an unsorted array of n elements, find if the element k is present in the array or not. Complete the  findNumber  function in the editor below. It has 2 parameters: An array of integers, arr, denoting the elements in the array. An integer, k, denoting the element to be searched in the array. The function must return a string "YES" or "NO" denoting if the element is present in the array or not. Input Format The first line contains an integer n, denoting the number of elements in the array arr. Each line  i  of the  n  subsequent lines (where  0 ≤ i < n ) contains an integer describing  arr i . The next line contains an integer, k, the element that needs to be searched.  Constraints 1 ≤ n ≤ 10 5 1 ≤ arr[i] ≤ 10 9 Output Format The function must return a string "YES" or "NO" denoting if the element is present in the array or not. This is printed to stdout by locked stub code in the editor. Explanation