algorithm about stackAndQueue