推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
withoutconscious
V2EX  ›  Python

Python 作业,复制栈原来的元素到栈顶,只能用一个额外的栈,求思路

  •  
  •   withoutconscious · Feb 22, 2022 · 2928 views
    This topic created in 1539 days ago, the information mentioned may be changed or developed.

    大佬们,这题要求复制栈元素,然后再塞到栈顶,只能用一个额外的栈和一个 integer 变量,咋做? 比如 : (Top) 1, 2, 3, 4, 5 (Bottom) ⇒ (Top) 1, 2, 3, 4, 5, 1, 2, 3, 4, 5 (Bottom)

    Write a function to duplicate the elements of stack s on top the original elements, by using only one additional queue q (initially empty), and one integer variable m. def dup_sq(s, q):

    2 replies    2022-02-22 17:48:48 +08:00
    Itoktsnhc
        1
    Itoktsnhc  
       Feb 22, 2022   ❤️ 1
    额外的队列吧
    withoutconscious
        2
    withoutconscious  
    OP
       Feb 22, 2022
    @Itoktsnhc 对哦,我没看仔细😂,那会做了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5700 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 07:04 · PVG 15:04 · LAX 00:04 · JFK 03:04
    ♥ Do have faith in what you're doing.