LoginSignup
0
0

More than 5 years have passed since last update.

スタック2つでキューを作る

Posted at

push 用 stack と pop 用スタックを用意する。
pop 用 stack が空になった場合、 push 用 stack の中身をひっくり返して投入する。
これで実装されたキューの実行時間は push/pop ともに平均O(1).

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0