this solution is giving error in leetcode because instead of low=max and our max is zero; we should use int low = *max_element(weights.begin(), weights.end()); btw nice explanation .
hi alisha just revisited the video I have a silly doubt this time (why we took int day = 1 initially inside bool func() ) instead of taking int day = 0. I saw this people generally take initial day or anything as 1 in similar binary search questions. Kindly please tell me why u guys do this? what is the intuition behind taking initial value as 1 instead of 0? thank you
the intuition behind this is lets suppose the minimum weight of the ship that could carry weight is 5 and in an array the elements are = [1,1,1,1,1] and you have to deliver it within 1 day. So the if condition will be executed according to the given condition sum + arr[i]