Hi, I am unable to rectify the mistake i have done in my code , two test cases are giving the wrong answer and rest are giving correct ans .
Two test cases are giving wrong result
s = arr[n-1];
is wrong
the aray need not be sorted always
take s as
for(int i = 0 ; i < n ; i++)
s = max( s ,a[i]) ;
still test case 2 is failing
ll s = *max_element(arr,arr+n);
ll e = 0;
for(ll i=0;i<n;i++)
{
e=e+arr[i];
}
ll ans = 0 ;
while(s<=e)
{
ll mid = (s+e)/2;
{
if(canread(arr,k,n,mid))
{
ans = mid;
e=mid-1;
}
updated code part
rest is same passing all test cases now
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.