In A Botanical Garden
In A Botanical Garden
In A Botanical Garden
counter directly. Each ticket has a ticket number and a slot number. The
security in-charge allows people to enter the garden only according to the
timeslot and ticket number. The people who have time slot 1 can enter the
garden before anyone with time slot 2. If more than one person from the
same time slot comes, they will be allowed according to their ticket
numbers.
If N people arrive at a time, find the order in which the security in-charge
allows them to enter the garden.
Sample Input 2:
5
65
82
15
64
61
Sample Output 2:
68616
Explanation 2:
N = 5.
There is only one person from time slot 1 and he gets to enter first. His
ticket number is 6, which is printed first.
There is only one person from time slot 2 and he gets to enter as the
second person. His ticket number is 8, which is printed next.
There is no one from time slot 3.
There is only one person from time slot 4 and he gets to enter as the
third person. His ticket number is 6, which is printed next.
There are two people from time slot 5: 6 and 1. Printing according to ticket
numbers gives 1 and 6 as the next entries in the output.
Printing all these ticket numbers gives 6 8 6 1 6 as the output.