Where Is the problem in the solution?

Where Is the problem in the solution?


You have to update the speeds as well of the cars which will slow down.


Here is your correct code. Please check it.

Why I need to update that?
I don’t understand the logic behind it.
Can You Please explain
Or with a test case.

You need to update it because the cars will slow down.
For example, if the maximum speeds are - 8, 11, 10 and they enter in the same order
Then first car will continue moving with a speed of 8. But second car will have to slow down as it can’t overtake and its new speed will become 8. So third car’s speed, being more than 8 can’t overtake the second car. So it will have to slow down as well.

Okayy, Understood Sir, Thanks a lot.

Okay that’s great. Please mark your doubt as resolved now.

Sir, Can’t I mark this resolve at this page?
And Can Give 5* here only?

I am not sure about that. I guess it must be somewhere in your Ask Doubts section.

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.