Test cases showing MLE

#include

using namespace std;

void alloccurances(int *a,long long int n,int num){
static int i = 1;
if(a[0]==num){
cout<<0<<’ ‘;
}
else{
if(a[i]==num){
cout<<i<<’ ';
}
else if(i==n){
return;
}
i++;
}
return alloccurances(a,n,num);
}

int main(){
int arr[100000];
long long int n;
cin>>n;

for(int i=0;i<n;i++){
    cin>>arr[i];
}
long long int x;
cin>>x;

alloccurances(arr,n,x);

}

hi @gunjit27_94aa0450736b408e i can see u got 100 points is the doubt still there?

I switched the code a little bit but I still dont know why this code was showing MLE

hi @gunjit27_94aa0450736b408e please send the code in ide.codingblocks.com

hi @gunjit27_94aa0450736b408e,
updated https://ide.codingblocks.com/s/668801

1 Like

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.