Can you send me the code of ispossible() function logic
PRANTHA PROBLEM
bool isSafe(int *a,int n,int p,int mid)
{
int k=0,j=1,sum=0;
for(int i=0;i<n;i++)
{
while(sum<=mid)
{
sum+=a[i]*j;
k++;
j++;
}
j=1;
k–;
sum=0;
}
if(k<p)
return false;
return true;
}
what’s wrong in my code?
plz rply me as early as possibel
Your code is giving compilation error. I think u should modify k- to k-- in ur code. Also initialise ans with zero and then try.