Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2-SunYerim #7

Merged
merged 2 commits into from
Mar 28, 2024
Merged

2-SunYerim #7

merged 2 commits into from
Mar 28, 2024

Conversation

SunYerim
Copy link
Member

๐Ÿ”— ๋ฌธ์ œ ๋งํฌ

ํ‚ค๋กœ๊ฑฐ

โœ”๏ธ ์†Œ์š”๋œ ์‹œ๊ฐ„

40๋ถ„

โœจ ์ˆ˜๋„ ์ฝ”๋“œ

ํ•ด๋‹น ๋ฌธ์ œ๋Š” ํ‚ค๋ณด๋“œ๋ฅผ ์ž…๋ ฅํ•  ๋•Œ ์™ผ์ชฝ ํ™”์‚ดํ‘œ, ์˜ค๋ฅธ์ชฝ ํ™”์‚ดํ‘œ, ๋ฐฑ์ŠคํŽ˜์ด์Šค๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ฌธ์ž์—ด์„ ํŽธ์ง‘ํ•˜๋Š” ์‹œ๋ฎฌ๋ ˆ์ด์…˜์„ ๊ตฌํ˜„ํ•˜๋Š” ๋ฌธ์ œ์˜€์Šต๋‹ˆ๋‹ค.

์šฐ์„  ๋ฌธ์ œ๋ฅผ ์ญ‰ ์ฝ์œผ๋ฉด์„œ ์Šคํƒ์„ ์‚ฌ์šฉํ•ด์„œ ํ’€์–ด์•ผ๊ฒ ๋‹ค๋Š” ๊ฒƒ๊นŒ์ง€๋Š” ํŒŒ์•…์„ ํ•˜๊ณ  ๋“ค์–ด๊ฐ”์—ˆ์Šต๋‹ˆ๋‹ค.
์ฒ˜์Œ์—๋Š” ์Šคํƒ ํ•˜๋‚˜๋กœ ํ•ด๊ฒฐ์„ ํ•ด๋ณด๋ ค๊ณ  ์• ๋ฅผ ์“ฐ๋‹ค๊ฐ€ ์‹œ๊ฐ„์„ ์ข€ ๋งŽ์ด ์“ด ๊ฑฐ ๊ฐ™์•„์š”. ๊ฒฐ๊ตญ, ๋‘ ๊ฐœ์˜ ์Šคํƒ์„ ์‚ฌ์šฉํ•˜์—ฌ ์™ผ์ชฝ๊ณผ ์˜ค๋ฅธ์ชฝ์˜ ์ปค์„œ๋ฅผ ํ‘œํ˜„ํ•˜๋Š” ๊ฒŒ ํ•ต์‹ฌ์ด์—ˆ๋˜ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค!

  • ์™ผ์ชฝ ์Šคํƒ: ์™ผ์ชฝ์— ์žˆ๋Š” ๋ฌธ์ž๋“ค์„ ์ €์žฅ
  • ์˜ค๋ฅธ์ชฝ ์Šคํƒ : ์˜ค๋ฅธ์ชฝ์— ์žˆ๋Š” ๋ฌธ์ž๋“ค์„ ์ €์žฅ

๋ฌธ์ œ์˜ ๋Œ€๋žต์ ์ธ ๋กœ์ง์ž…๋‹ˆ๋‹ค.

1. ์ž…๋ ฅ ๋ฐ›์€ ๋ฌธ์ž์—ด์„ ํ•œ ๊ธ€์ž์”ฉ ๋ฐ˜๋ณตํ•˜์—ฌ ์ฒ˜๋ฆฌ
2. '<'๋ฅผ ๋งŒ๋‚˜๋ฉด ์™ผ์ชฝ ์Šคํƒ์—์„œ popํ•˜์—ฌ ์˜ค๋ฅธ์ชฝ ์Šคํƒ์— pushํ•ฉ๋‹ˆ๋‹ค. ์ด๋Š” ์ปค์„œ๋ฅผ ์™ผ์ชฝ์œผ๋กœ ์ด๋™
3. '>'๋ฅผ ๋งŒ๋‚˜๋ฉด ์˜ค๋ฅธ์ชฝ ์Šคํƒ์—์„œ popํ•˜์—ฌ ์™ผ์ชฝ ์Šคํƒ์— pushํ•ฉ๋‹ˆ๋‹ค. ์ด๋Š” ์ปค์„œ๋ฅผ ์˜ค๋ฅธ์ชฝ์œผ๋กœ ์ด๋™์‹œํ‚ค๋Š” ๋™์ž‘
4. '-'๋ฅผ ๋งŒ๋‚˜๋ฉด ์™ผ์ชฝ ์Šคํƒ์—์„œ popํ•˜์—ฌ ํ•ด๋‹น ๋ฌธ์ž๋ฅผ ์‚ญ์ œํ•ฉ๋‹ˆ๋‹ค. ๋‹จ, ์™ผ์ชฝ ์Šคํƒ์ด ๋น„์–ด์žˆ์œผ๋ฉด ๋ฌด์‹œ
5. ๋‚˜๋จธ์ง€ ๋ฌธ์ž๋Š” ์™ผ์ชฝ ์Šคํƒ์— push

์ž…๋ ฅ์„ ๋ชจ๋‘ ์ฒ˜๋ฆฌํ•œ ํ›„์—๋Š” ์™ผ์ชฝ ์Šคํƒ์— ์žˆ๋Š” ๋ฌธ์ž๋“ค์„ StringBuilder์— ์ถ”๊ฐ€ํ•œ ๋’ค, ์˜ฌ๋ฐ”๋ฅธ ์ˆœ์„œ๋กœ ๋ฌธ์ž๋ฅผ ์ถœ๋ ฅํ•˜๊ธฐ ์œ„ํ•ด ์˜ค๋ฅธ์ชฝ ์Šคํƒ์— ์žˆ๋Š” ๋ฌธ์ž๋“ค์„ ์—ญ์ˆœ์œผ๋กœ StringBuilder์— ์ถ”๊ฐ€ํ•ด์•ผํ•ฉ๋‹ˆ๋‹ค.

(์ด๋ฒˆ์ฃผ๋Š” ๋„ˆ๋ฌด ์ •์‹ ์—†์ด ์ง€๋‚˜๊ฐ€์„œ ,,, ์‹ค๋ฒ„๋ฌธ์ œ๋ฅผ ์žก์•„์„œ ํ’€์—ˆ์Šต๋‹ˆ๋‹ค ๐Ÿ˜‚ ๊ทธ๋ ‡์ง€๋งŒ ๋˜ ์ƒ๊ฐํ•  ๊ฒƒ๋“ค์ด ์žˆ๋”๋ผ๊ตฌ์š”..)

๐Ÿ“š ์ƒˆ๋กญ๊ฒŒ ์•Œ๊ฒŒ๋œ ๋‚ด์šฉ

๋ฌธ์ œ ์ ‘๊ทผ๋ฐฉ์‹์„ ์ƒ๊ฐํ• ๋•Œ๋Š” .. ๊นŠ๊ฒŒ ๊ณ ๋ฏผํ•ด๋ณด๊ณ  ์•ˆ ๋  ๊ฑฐ ๊ฐ™์œผ๋ฉด ๋น ๋ฅด๊ฒŒ ๋…ธ์„ ์„ ๋ณ€๊ฒฝํ•˜์ž ๐Ÿ˜…

Copy link
Collaborator

@wjdheesp44 wjdheesp44 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ €๋„ ์Šคํƒ 2๊ฐœ ์‚ฌ์šฉํ•ด์•ผ ํ•œ๋‹ค๊ณ  ์ƒ๊ฐํ•˜๊ธฐ๊ฐ€ ํž˜๋“ค์—ˆ๋˜ ๊ฒƒ ๊ฐ™์•„์š”
์•ž์œผ๋กœ๋Š” ์Šคํƒ์„ 2๊ฐœ ์ด์ƒ์œผ๋กœ๋„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Œ์„ ์—ผ๋‘์— ๋‘๊ณ  ๋ฌธ์ œ๋ฅผ ๋ด์•ผ๊ฒ ์–ด์š”!
๊ณ ์ƒํ•˜์…จ์Šต๋‹ˆ๋‹ค!

Copy link
Collaborator

@erase-jeong erase-jeong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๊ฐ€๋ฌผ๊ฐ€๋ฌผํ•˜๊ธด ํ•˜์ง€๋งŒ, ์˜ˆ์ „์— ์ด์‚ฐ์ˆ˜ํ•™ ๊ณผ๋ชฉ์—์„œ ์ด ๋‚ด์šฉ๊ด€๋ จํ•ด์„œ ๋ฐฐ์› ๋˜ ๊ฒƒ๋„ ์ƒ๊ฐ๋‚˜๋„ค์š”. ์ €๋Š” ์Šคํƒ 2๊ฐœ๋ฅผ ์ด์šฉํ•ด์„œ ํ’€ ์ƒ๊ฐ์„ ๋ชปํ•ด์„œ ์—ฐ์†์œผ๋กœ '>' ์—ฐ์‚ฐ์ž 2๊ฐœ ๋‚˜์˜จ๊ฑฐ ์–ด๋–ป๊ฒŒ ์ฒ˜๋ฆฌํ• ์ง€ ๊ณ ๋ฏผํ–ˆ์—ˆ๋„ค์š”.

String input = br.readLine();
Stack<Character> lStack = new Stack<>();
Stack<Character> rStack = new Stack<>();

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stack stack= new Stack<>(); ๋ณด๋‹ค๋Š”
Deque deque = new ArrayDeque<>(); ์“ฐ๋Š”๊ฒŒ ๋” ์†๋„๊ฐ€ ๋น ๋ฅผ๊ฒ๋‹ˆ๋‹ค
๋™๊ธฐ, ๋น„๋™๊ธฐ ์ฐจ์ด๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋„ค ์•Œ๊ณ ๋Š” ์žˆ์—ˆ๋Š”๋ฐ ์ต์ˆ™์น˜๊ฐ€ ์•Š์•„์„œ, Stack<>์œผ๋กœ ์„ ์–ธํ•ด์„œ ๋ฌธ์ œ๋ฅผ ํ’€์—ˆ๋„ค์šฉ
์ฐธ๊ณ ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค -! ๐Ÿ˜

@SunYerim SunYerim merged commit c74d29f into main Mar 28, 2024
@SunYerim SunYerim deleted the 2-SunYerim branch March 28, 2024 01:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants