https://hack.codingblocks.com/app/practice/2/1044/problem
here is my different approach to solve the question but my
test case 0 got passed
test case 1 is showing run error
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
int n;
cin>>n;
int arr[100];
for(int i=0;i<n;i++)
{
cin>>arr[i];
}
int key;
cin>>key;
auto it=find(arr,arr+n,key);
int index=it-arr;
if(index==n)
cout<<-1<<endl;
else
cout<<index;
return 0;
}
