All test cases showing wrong

#include<bits/stdc++.h>
using namespace std;

void Search(int *A,int n,int x)
{
int first=0;
int last=0;
auto lb=lower_bound(A,A+n,x);
first=lb-A;

if(first==n)
   cout<<-1<<" ";

else
   cout<<first<<" ";

auto ub=upper_bound(A,A+n,x);
if(ub>A+n)
{
    last=(ub-A)-1;
    cout<<last<<" ";
}
else
    cout<<-1<<" ";

}

int main()
{
int n,i,x;
cin>>n;
int *A=new int[n];
for(i=0;i<n;i++)
cin>>A[i];
int q;
cin>>q;
while(q>0)
{
cin>>x;
Search(A,n,x);
cout<<endl;
q–;
}

}

hi @Mukul-Shane-1247687648773500,
check this https://ide.codingblocks.com/s/655872, ive updated your code and commented

i guess this is the same doubt hehe no worries keep coding :slight_smile:

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.