Ad
  • Default User Avatar

    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.

  • Custom User Avatar

    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)

  • Custom User Avatar

    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.

  • Custom User Avatar

    Hey How you solved with single for loop

  • Custom User Avatar

    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

  • Custom User Avatar

    Please, put spoiler flag before posting your code next time. It's right above the "Post"/"Reply" button.

    img

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution