What is the code for this? C++ Input Format: The first line consists of 2 integers N and M denoting the size of the array and the element to be searched for in the array respectively . The next line contains N space separated integers denoting the elements of the array. Output Format: Print a single integer denoting the index of the first impostor to be found of integer M in the array if it exists, otherwise print “There is no impostor among us”. Constraints 1 <= N <= 1000 1 <= A[i] <= 1000 1 <= M <= 1000 Sample Output: Example 1: 5 1 1 2 3 4 1 The first impostor is found at position 1. Example 2: 6 4 1 2 3 4 1 2 The first impostor is found at position 4. Example 3: 5 6 1 2 3 4 1 2 There is no impostor among us.
What is the code for this? C++
Input Format:
The first line consists of 2 integers N and M denoting the size of the array and the element to be searched for in the array
respectively . The next line contains N space separated integers denoting the elements of the array.
Output Format:
Print a single integer denoting the index of the first impostor to be found of integer M in the array if it exists, otherwise print
“There is no impostor among us”.
Constraints
1 <= N <= 1000
1 <= A[i] <= 1000
1 <= M <= 1000
Sample Output:
Example 1:
5 1
1 2 3 4 1
The first impostor is found at position 1.
Example 2:
6 4
1 2 3 4 1 2
The first impostor is found at position 4.
Example 3:
5 6
1 2 3 4 1 2
There is no impostor among us.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images