Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- Stack and Queue being implemented with Python List.
- Both structures follow the design below:
- Bottom -> [...] -> Top.
- """
- def dequeue(array: list) -> int:
- return array.pop()
- def empty_one_fill_the_other(stack1: list, stack2:list):
- while len(stack1) > 0:
- value = stack1.pop()
- stack2.append(value)
- return stack2
- def main():
- stck_one = [1,2,3]
- stck_two = []
- queue = empty_one_fill_the_other(stck_one, stck_two)
- # After this, we should re do the same step in the other
- # direction, to keep the initial state intact.
- # Should be equal to 1.
- print(dequeue(queue))
- if __name__ == "__main__":
- main()
Add Comment
Please, Sign In to add comment