Find Upper And Lower Bound TestCases are failing help me to debug

#include
#include<bits/stdc++.h>
#define l long long int
using namespace std;

int main(){
l n;
cin>>n;
l a[n];
for(l i=0;i<n;i++){
cin>>a[i];
}
l q;
cin>>q;
for(l i=0;i<q;i++){
l x;
cin>>x;
auto it = lower_bound(a,a+n,x);
auto it2 = upper_bound(a,a+n,x);
if(it-a == n){
cout<<-1<<" “<<-1<<endl;
}
else{
cout<<it-a<<” "<<it2-1-a<<endl;
}
}
return 0;
}

@amangoel987357 you also need to make sure that the given number is present in the array, so add an addition condition with it-a == n that *it != x, which would change the if condition to if(it-a == n || *it != x)

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.