In this code, the brute force way is to do
if (load%n)!=0
cout<<-1
else
cout<<load/n
what’s the point of doing the greedy part here?
In this code, the brute force way is to do
if (load%n)!=0
cout<<-1
else
cout<<load/n
what’s the point of doing the greedy part here?
Hey @sonalbera why we are using greedy approach is because we have to find the difference between final load to be assigned and current load too. Also, what bhaiya has explained is int the last for loop in the video the difference is keeping track of the currently request transfers and max load which is keeping track of the max possible transfer that can happen . See the three cases that bhaiya ran on the terminal in the end dry run the code for them you will understand whole concept of why greedy was used after doing these operations.
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.