Ad
  • Default User Avatar

    Ahh, you mean every person swaps with the person who has the same index from the other side of the queue (with respect to the 1's and 3's). that's not really clear at first, I thought we would swap everyone with the last person in the line.

  • Custom User Avatar

    In the instructions, it states that only known guests and members (1 and 2 respectively) can "cut" in front of the others, meaning they get sorted to the front, while everybody else has to maintain their position in line. In [1,1,3,2,0], all the 1's and 2's get moved to the front (the two just gets moved in front of the 3), while everything else maintained their position in line (0 remained at the end since it isn't sorted).

  • Default User Avatar

    How to understand where 0 should stand after sort? In the first example:
    "queue = [1, 1, 3, 2, 0] # The given queue
    sorted = [1, 1, 2, 3, 0] # Sorted by priority" zero is taking the last place.
    But in the second one its standing right after all twos:
    "queue = [0, 8, 2, 1, 4, 2, 12, 3, 2] # The given queue
    sorted = [1, 2, 2, 2, 0, 8, 4, 12, 3] # Sorted by priority"
    This one is from discussion:
    [1, 1, 1, 2, 2, 3, 4, 5, 0, 8, 5, 6]
    Where to put zero and where should be decoys in sorted queue?

  • Custom User Avatar

    You have to create the algorithm to swap it. You sort it so that it has the proper order for you to be able to swap correctly. Re-read the scenario and take a look at the step-by-step examples underneath.

  • Default User Avatar

    I don't understand why do we swap even after the queue had been sorted, and what is the algorithm that we use to swap after sorted?

  • Default User Avatar

    Well, I've been able to get the index of the digit we want in the corresponding element, like if (n) is 9.
    then I know that its index is 3 in the 4th element, and the number of digits of the element is 4.
    Am I going the right way? (C++)

  • Default User Avatar

    Yeah, you're correct. After adding new line after each test case, it really isn't.

  • Custom User Avatar

    Probably you're printing the input of more than one test and confusing that with a single test input.

  • Default User Avatar

    Didn't he say "All numbers are equal except for one"? then why there are some test cases that has multiple values?