Question: Given an unsorted array of n elements, find if the element k is present in the array or not. Complete the find-Number function. It has

Given an unsorted array of n elements, find if the element k is present in the array or not. Complete the find-Number function. It has 2 parameters:
1. An array of integers, arr, denoting the elements in the array.
2. 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; The next line contains an integer, k, the element that needs to be searched.
Constraints:
1<_n<_10^5
1<_arr[i]<_10^10
Output Format: The function must return a string "YES" or "NO" denoting if the leement is presend in the array or not.
Sample input 0
5,1,2,3,4,5,1
Sample Output 0
YES
Explanation 0: Given the array=[1,2,3,4,5], we want to find the element 1 if it is presend or not. We can find the element 1 at index=0 Therefore we print "YES"

Step by Step Solution

3.46 Rating (153 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The question is incomplete due to formatting errors and missing constraint details Here is a corrected and complete version of the question along with ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!