deque

    [JAVA] ๋ฐฑ์ค€ 5430๋ฒˆ ใ€ACใ€‘

    ์ฃผ๋ง์— ํ• ์ผ์ด ์—†์–ด์„œ ์ƒˆ๋กœ์šด ์–ธ์–ด๋ฅผ ๋งŒ๋“  ์„ ์˜์”จ....ใ…Ž ์ด ๋ฌธ์ œ๋ฅผ ํ’€๋ฉด์„œ ๋– ์˜ฌ๋ ธ๋˜ ์•„์ด๋””์–ด๋Š” R์„ ์ž…๋ ฅ๋ฐ›์„๋•Œ๋งˆ๋‹ค ๋’ค์ง‘์€ ๋ฐฐ์—ด์„ ์ƒˆ๋กœ ์ •์˜ํ•˜๋Š” ๊ณผ์ •์€ ์ ˆ๋Œ€ ์žˆ์–ด์„œ๋Š” ์•ˆ๋  ๊ฒƒ ๊ฐ™๋‹ค๊ณ  ์ƒ๊ฐ์ด ๋“ค์—ˆ๋‹ค. queue ๋‚˜ stack ์•„๋‹ˆ๋ฉด deque ๋ฅผ ์ ์ ˆํžˆ ํ™œ์šฉํ•˜๋ฉด, ์ถฉ๋ถ„ํžˆ ๊ตฌํ˜„ ๊ฐ€๋Šฅํ•œ ๋ฐฉ๋ฒ•์ด์ง€๋งŒ, ์„ฑ๋Šฅ์ด ๋งค์šฐ ๋–จ์–ด์งˆ ๊ฒƒ์ด๋ผ๊ณ  ์ƒ๊ฐ์ด ๋“ค์—ˆ๊ณ  ๋‹จ์ง€, R ๋ช…๋ น์ด ๋ช‡๋ฒˆ ๋“ค์–ด์™”๋Š”์ง€ ๊ธฐ๋กํ•˜๊ณ , R ๋ช…๋ น์˜ ๊ฐฏ์ˆ˜์— ๋”ฐ๋ผ ๋’ค์—์„œ๋ถ€ํ„ฐ ์ง€์šธ์ง€ ์•ž์—์„œ๋ถ€ํ„ฐ ์ง€์šธ์ง€๋งŒ ๊ฒฐ์ •ํ•˜๋ฉด ๋œ๋‹ค๊ณ  ์ƒ๊ฐํ–ˆ๊ณ , ๊ทธ๋ ‡๊ฒŒ ๊ตฌํ˜„ํ•˜์˜€๋‹ค. deque ์— [1 2 3 4 5] ๊ฐ€ ์ž…๋ ฅ๋˜์–ด์žˆ๋‹ค๊ณ  ๊ฐ€์ •ํ–ˆ์„ ๋•Œ, deque์˜ poll() ์€ 1์„ ์‚ญ์ œํ•˜๊ณ  R์„ ํ™€์ˆ˜๋ฒˆ ์ž…๋ ฅ๋ฐ›์•„ ์—ญ์ˆœ์ด ๋˜์—ˆ๋‹ค๊ณ  ๊ฐ€์ •ํ–ˆ์„๋•Œ, D ๋ช…๋ น์„ ๋™์ž‘ํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด deque์˜ removeLast()๋ฅผ..