i am not able to find out where i am getting wrong.can u please me the mistakes.
Painters problem
Hello @lovely as i told you yesterday also that this logic of yours is wrong. so now i will explain you now.
just ine question did you watch the hint video for this question?
yes i watched it and tried again .then asked
@lovely okay no problem .
see in this question you have to first select the range in this question on which you will apply the binary search.
like in this first you will define start in this start will be the maximum element in the array because if there are n number of painters available then the min time is the maxtime in the element.
and end in this will be the sum of all elements because if there is only one element then you have to take the sum of all elements because only one painter is available, so only one painter is available to paint them thats why it is the min time only.
then you will make your check function whether you can allocate them in that you will check if the painter allocates is 1 and in then if the board time for that incrementedwith the previous sum if greater then the mid then you will ask one more painter to help and then youu will change the sum to the current only.
and in that you will check if the number of painters is greater then the total painters then youwill return false but if you are able to allocate the all then you will return true.
Here for your reference i am ataching the code:
if you have any doubt you can ask here:
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.