Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
The task is really not well written. It seems that it was written by a not very sane person. Because the example of 10 chairs and 10 patients was the most confusing. I realized that the essence lies in the difference of numbers. Well, like the first chair is occupied, then try to sit on another. I advise you to finalize the task, otherwise, the point is that they are trying not to explain the task to us, but to confuse it as much as possible, because if I would refer to their explanations, then, in general, my solution is completely wrong. By the way, I spent half a day because of three lines of code.
Hi Anorey I've actually approached the problem with same way just look at the time complexity it could easily by resolved by o(1)
Hahaha It's way to simple you just need to understand the problem.
solution lies in problem representation and arrangement no loop nothing required.
I was scracthing my head first.
Hey How you solved with single for loop
This is quite good solution if you look code wise but time complexity wise it is not! You're iterating over the same array 3 times.
A Good solution would be with normal for-loop
Please, put spoiler flag before posting your code next time. It's right above the "Post"/"Reply" button.
This comment is hidden because it contains spoiler information about the solution