Did not understand whats going on code

did not understand whats going on code

in the video bhaiya has applied greedy approach

what the question is asking is to assign different teams the desired/ nearest to desired rank so that the badness is minimum

so each time u encounter a team with x rank
u do the abs( x - assignable rank ) add this to badness variable
this would give the minimum badness value

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.