why is the last test case failing
Test case failing
Hi @itida_99
it is showing wrong ans in the case when in the for loop when s turns out to be 0 then you are printing no and again after the for loop again in if case where s<k there also you are printing no. so in that case your output is NoNo which is wrong. So to correct this in if case where s==0 there instead of break use return 0.
if(s<=0){
cout<<“No”;
flag=0;
return 0;
}