bag of numbers
Submit solution
Python
Points:
10 (partial)
Time limit:
10.0s
Memory limit:
64M
Author:
Problem type
Allowed languages
Bag of Numbers
Vikas is given a bag which consists of numbers (integers) blocks,Vikas has to organize the numbers again in the same order as he has inserted it into the bag, i.e. the first number inserted into the bag by Vikas should be picked up first followed by other numbers in series. Help Vikas to complete this work in O(n) time complexity with the condition to use one extra bag to complete the work (assume that the bags are compact and is in the form of a stack structure and has the same width as that of the number blocks and is large enough to fill the bag to the top and the number taken from bag is in reverse order).
Hint: use the concept of Stacks.
input: 15 21 39 390 392 380.
output: 15 21 39 390 392 380.
Comments