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

๐Ÿง‘โ€๐Ÿ’ป Week 5 #4

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

jxixeun
Copy link

@jxixeun jxixeun commented Mar 15, 2023

๋ฌธ์ž์—ด

@jxixeun
Copy link
Author

jxixeun commented Mar 15, 2023

๊ฐ„๋‹จ ๋ฆฌ๋ทฐ

๋ฌธ์ž์—ด ๊ฒŒ์ž„2 ๐Ÿ’Œ

์•ŒํŒŒ๋ฒณ ํฌ๊ธฐ๋งŒํผ์˜ ๋ฆฌ์ŠคํŠธ๋ฅผ ๋งŒ๋“ค๊ณ (28๊ฐœ) ๊ฐ ๋ฆฌ์ŠคํŠธ์— ๋ฌธ์ž์—ด์—์„œ ํ•ด๋‹น ์•ŒํŒŒ๋ฒณ์ด ์กด์žฌํ•˜๋Š” ์ธ๋ฑ์Šค๋ฅผ ์ €์žฅํ–ˆ๋‹ค.
๊ทธ ๋‹ค์Œ ์ธ๋ฑ์Šค์˜ ์ฐจ๋ฅผ ๊ตฌํ•ด์„œ ์ตœ์†Œ์™€ ์ตœ๋Œ€๋ฅผ ๊ตฌํ•ด์คฌ๋‹ค.
์˜ˆ๋ฅผ ๋“ค์–ด ๋ฌธ์ž์—ด์—์„œ a๊ฐ€ ์กด์žฌํ•˜๋Š” ์ธ๋ฑ์Šค๊ฐ€ 1,3,5,8์ผ ๋•Œ ๋ฌธ์ž 3๊ฐœ๋ฅผ ํฌํ•จํ•ด์•ผํ•˜๋Š” ๊ฒฝ์šฐ์—๋Š” ์ฒ˜์Œ ์ธ๋ฑ์Šค๋ฅผ 0,2(i,j)๋กœ ์žก๊ณ  a ๋ฆฌ์ŠคํŠธ์—์„œ get(2)-get(0) +1์„ ํ•˜๊ณ  (์ธ๋ฑ์Šค๊ฐ€ 0๋ถ€ํ„ฐ ์‹œ์ž‘ํ•˜๋ฏ€๋กœ +1์„ ํ•ด์ค˜์•ผ ๊ธธ์ด๊ฐ€ ๋‚˜์˜จ๋‹น.) ๊ฐ๊ฐ ์ธ๋ฑ์Šค์— i++, j++์„ ํ•ด์ค€๋‹ค. j๊ฐ€ a ๋ฆฌ์ŠคํŠธ์˜ ํฌ๊ธฐ๋ณด๋‹ค ์ž‘์„๋•Œ๊นŒ์ง€ ๋ฐ˜๋ณต๋ฌธ์„ ๋Œ๋ ค์ค€๋‹ค.
์œ„์˜ ์˜ˆ์‹œ์˜ ๊ฒฝ์šฐ 5-1+1, 8-3+1์ด ๋˜์–ด์„œ ์•ž์€ 5, ๋’ค๋Š” 6์ด ๋œ๋‹ค. ๊ทธ๋ž˜์„œ ์ตœ์†Ÿ๊ฐ’์€ 5๊ฐ€ ๋˜๊ณ  ์ตœ๋Œ“๊ฐ’์€ 6์ด ๋œ๋‹ค. ์ด๊ฑธ a๋ถ€ํ„ฐ z๊นŒ์ง€ 28๋ฒˆ ๋Œ์•„์„œ ์ฐ์ตœ์†Ÿ๊ฐ’๊ณผ ์ฐ์ตœ๋Œ“๊ฐ’์„ ๊ตฌํ•œ๋‹ค. ์ฐ์ตœ์†Ÿ๊ฐ’์ด 3๋ฒˆ๋‹ต์ด๊ณ  ์ฐ์ตœ๋Œ“๊ฐ’์ด 4๋ฒˆ ๋‹ต์ด๋‹น!! ๐Ÿ˜„

๋ฌธ์ž์—ด ํญ๋ฐœ ๐Ÿ’ฃ

์ฒ˜์Œ์— ์Šคํƒ์„ ์‚ฌ์šฉํ•ด์„œ prefix ์Šคํƒ๊ณผ suffix ์Šคํƒ์„ ๋งŒ๋“ค์–ด์„œ ํ–ˆ๋Š”๋ฐ ์‹œ๊ฐ„์ดˆ๊ณผ๊ฐ€ ๋‚ฌ๋‹ค. ใ…œ ๐Ÿ˜ข
๊ฒ€์ƒ‰ํ•ด๋ณด๋‹ˆ StringBuilder๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๋œ๋‹ค๊ณ  ํ•ด์„œStringBuilder๋ฅผ ์‚ฌ์šฉํ•ด์„œ ํญ๋ฐœ ๋ฌธ์ž์—ด์˜ ๊ธธ์ด๋ณด๋‹ค ๊ธธ ๋•Œ, ๋’ค์—์„œ๋ถ€ํ„ฐ ํญ๋ฐœ๋ฌธ์ž์—ด์˜ ๊ธธ์ด๋งŒํผ์˜ ๋ฌธ์ž์—ด์„ ๋น„๊ตํ•˜๊ณ  ๋งž์„ ๊ฒฝ์šฐ delete๋ฅผ ํ•ด์คฌ๋‹ค.
StringBuilder์— delete ํ•จ์ˆ˜๊ฐ€ ์žˆ๋Š”๊ฑธ ์˜ค๋Š˜ ์ฒ˜์Œ ์•Œ์•„์„œ ์—ฌํƒœ๊นŒ์ง€ ๋งŽ์ด ์†ํ•ด๋ณธ ๊ฑฐ ๊ฐ™๋‹ค......ใ…  Noooooooooooooo

jxixeun added 15 commits March 28, 2023 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant