solve stack push and pop