output is correct still not passing the test case
First_negative_integer
WILL you see what’s the mistake I’m doing
include # include using namespace std; void first(int a[],int n,int k){ queue q; int i=0; bool ispresent ; bool zero_present; for(i=0;i<n;i++){ zero_present = false; ispresent = false; for(int j=i;j<i+k and (i+k)<=n;j++){ if(a[j]<0){ q.push(a[j]); ispresent = true; zero_present = false; break; } else if(ispresent == false){ zero_present = true; } } } while(!q.empty()){ cout<<q.front()<<" “; q.pop(); } if(zero_present==true){ cout<<0<<” "; } } int main(){ int t; cin>>t; while(t–){ int n,k; cin>>n>>k; int a[n]; for(int i=0;i<n;i++){ cin>>a[i]; } first(a,n,k); cout<<endl; } return 0; }
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.