Here stalls are located in random manner so is it necesseary to sort the stalls …beacuse without sorting i am getting 4 as the largest minimum separation…which is true also for 1 2 8 4 9 …having 3 cows…
But this approch i am not passing any testcases…
When i sort the array and then calculate the minimum distance it passed all test cases.
1)https://onlinegdb.com/Hko5HpQbD (wrong answer)
2)https://onlinegdb.com/SJfhH6XZD (Rigth answer) Please explain this
Confusion in question
You have to sort the array in order to apply binary search
But we are not applying the binary search on this array… The “sta” and “end” which we have created …we are applying binary search on that… didn’t we??
You should apply binary search on the minimum distance between any two cows.
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.