Last test case remaining

the last test case is not passing

hey @abhi18sinha could you please explain your logic of chosing your range becuase i dont think it is the correct logic .
as you have to apply the binary search on the gap between barns for which the range would be from 1 to a[n-1]-a[0] .
if your range is wrong or either there could be error in your possible function also .
becuase there also you have to find the difference and then you will compare on the basis of the difference .

please let me know your approach

As you said that we have to compare the difference in between the consecutive barns, so what I did is that I calculated the gap between every consecutive barn and then put that value in the array b and then I just compared the values at every index of b.
Regarding the range, I did the total sum of the array b as (the sum of all the gaps in between the consecutive barns) = a[n-1] - a[0]
It is successfully passing 4 out of 5 test cases.

hey @abhi18sinha the last test case is very big and your code is producing the wrong output for that
.
your code is returning the value of int_min for that case .
here i am attaching the correct code in which i am making comparison at the timeof checking if possible or not .


i hope i have cleared your doubt .
Happy Learning!!

hello @abhi18sinha I hope I’ve cleared your doubt. I ask you to please mark this doubt as resolved .
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.
Happy Learning !!

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.