-
Notifications
You must be signed in to change notification settings - Fork 98
feat: Lv4 ๊ฐ์ฌ ๊ฒ์, ๋ฌด์ง์ ๋จน๋ฐฉ ๋ผ์ด๋ธ ํ์ด ์ถ๊ฐ #113
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
๊ธฐ์ฌํด์ฃผ์
์ ๊ฐ์ฌํฉ๋๋ค!! ์ฝ๋ ์คํ์ผ๋ ํ์คํ์๊ณ , ๊น๋ํ๊ฒ ์์ฑ๋์ด์์ด์ ํฌ๊ฒ ์ฝ๋ฉํธ ํ ๊ฒ ์์์ต๋๋ค!
ํ์๋ ์ ๋ง์ถฐ์ฃผ์
์ ๋ฐ๋ก approve ํ๋๋ก ํ๊ฒ ์ต๋๋ค ๐
๊ฐ์ด ํ ํด๋ณด๊ณ ์ถ์๋๋ฐ ์์ฝ๋ค์!! ์ฐ๋ฝ ์ฑ๋์ด ์์ด์ ํน์ ๋ณด์๋ฉด codeisneverodd@gmail.com๋ก ๋ฉ์ผ ํ๋๋ง ๋ณด๋ด์ฃผ์ค ์ ์์๊น์?! @ryong9rrr
} | ||
|
||
// stack์ผ๋ก ํ๊ธฐ | ||
const stack = food_times.map((time, i) => [time, i + 1]).sort((a, b) => b[0] - a[0]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sort ๊ตฌ๋ฌธ ๋ฐ๋ก ์์ 0๋ฒ ์ธ๋ฑ์ค๊ฐ time์ ์๋ฏธํ๋ ๊ฒ์ด ๋ช ์๊ฐ ๋์ด์์ด์ ํฌ๊ฒ ํ์ํ์ง ์์ง๋ง ๋ค์๊ณผ ๊ฐ์ ํํ๋ ๊ณ ๋ คํด๋ณด์ธ์! ์คํ์ผ ์ฐจ์ด์ธ ๊ฒ ๊ฐ์ต๋๋ค ๐
const stack = food_times.map((time, i) => [time, i + 1]).sort(([timeA], [timeB]) => timeB - timeA);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์๋ฏธ๊ฐ ๋ ๋ช ํํด์ง๋ ๊ฒ ๊ฐ๋ค์ ๐๐
|
||
let prev = 0 | ||
while (stack.length > 0 && k >= 0) { | ||
const time = stack[stack.length - 1][0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
๋ค์๊ณผ ๊ฐ์ ๊ตฌ์กฐ๋ถํด ํ ๋น ์คํ์ผ๋ ๊ณ ๋ คํด๋ณด์ธ์! ์ ๋ ์ด ์คํ์ผ์ด ์กฐ๊ธ ๋ ์๋ฏธ๋ฅผ ํ์ ํ๊ธฐ ์ฝ๋ค๊ณ ์๊ฐํ๋๋ฐ ์ด๋ป๊ฒ ์๊ฐํ์๋์?? @ryong9rrr ๋ ์๊ฒฌ์ด ๊ถ๊ธํ๋ค์!
const [time] = stack[stack.length - 1];
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ฌ์ํ ๋ถ๋ถ์ธ๋ฐ ํจ์ฌ ๋์์ง๋ค์!!! ๐๐๐
const result = stack | ||
.reverse() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reverse ๋ฉ์๋๋ ์๋ณธ ๊ฐ์ฒด๋ฅผ ๋ณํ์ํค๋ side effect๊ฐ ์์ต๋๋ค! ๋ฐ๋ผ์ ์๋ํ ๊ฒ์ด ์๋๋ผ๋ฉด ๋ณต์ฌ๋ณธ์ ์์ฑํ์ฌ reverse๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์ด ์ข์ต๋๋ค ๐
const result = [...stack] .reverse()
sort๋ ๋ง์ฐฌ๊ฐ์ง๋ก ์๋ณธ ๊ฐ์ฒด๋ฅผ ๋ณํ์ํค์ง๋ง, 11๋ฒ ๋ผ์ธ์์๋ map์ ์ฌ์ฉํ์ฌ ๋์จ ๋ณต์ฌ๋ณธ์ sort๋ฅผ ํ์๊ธฐ ๋๋ฌธ์ food_times
์๋ณธ ๋ฐฐ์ด์๋ ์ํฅ์ ๋ผ์น์ง ์์์ ๊ฒ์
๋๋ค!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์๋ ์ด ์ฝ๋๊ฐ ํ์ด์ฌ์ "ํ"๋ฅผ ์ฌ์ฉํ ํ์ด์๋๋ฐ, ์๋ฐ์คํฌ๋ฆฝํธ๋ก ์์ฑํ๋ฉด์ ํ๋ฅผ ์คํ์ผ๋ก ์ ํํด์ ํ์ดํ๊ฒ ๋์ด์. ๊ทธ๋ฌ๋ค๋ณด๋ ์๋์ ์ผ๋ก ์คํ์ ๋ค์ง์์ต๋๋ค ใ ใ
๋ง์ฝ ์คํ ๋ฐ์ดํฐ๋ฅผ ์ ์ง์์ผ์ผ ํ๋ ๊ฒฝ์ฐ๋ผ๋ฉด ๋ง์๋๋ก ๋ณต์ฌ๋ณธ์ ์์ฑํ๋ ๊ฒ์ด ๋ง์ต๋๋ค!!
|
||
const result = stack | ||
.reverse() | ||
.map((item) => item[1]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
item์ 1๋ฒ ์ธ๋ฑ์ค๊ฐ ์๋ฏธํ๋ ๊ฒ์ ์์์๋ถํฐ ๊ธฐ์ตํ๋ฉฐ ์ค๊ธฐ ์ด๋ ค์ธ ์ ์์ผ๋ ๋ค์๊ณผ ๊ฐ์ ํํ๋ ๊ณ ๋ คํด๋ณด์ธ์!
.map(([_, order]) => order)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์๋ฏธ๊ฐ ํจ์ฌ ๋ช ํํด์ง๋๋ค ใ ใ ๋ฐ์์คํ ๋ฐ ๋ฆฌ๋ทฐ ๊ฐ์ฌ๋๋ ค์ ๐ฅฐ
@codeisneverodd <๋ฌด์ง์ ๋จน๋ฐฉ ๋ผ์ด๋ธ> ์ฝ๋๋ฆฌ๋ทฐ ๋ฐ์ํด์ ์ปค๋ฐ ์ฌ๋ ธ์ต๋๋ค! ์๊ฐ๋์ค ๋ ๋ฉ์ผ๋ ํ์ธํด์ฃผ์ธ์ ๐ |
์๋กญ๊ฒ ์ถ๊ฐ๋ ๋ฌธ์ ํ์ด
4 / ๋ฌด์ง์ ๋จน๋ฐฉ ๋ผ์ด๋ธ 9e5c6fb
4 / ๊ฐ์ฌ ๊ฒ์ 7350eb5
๊ธฐ์กด ํ์ด์ ์ถ๊ฐํ ํ์ด
๊ด๋ จ ์ด์