-
Notifications
You must be signed in to change notification settings - Fork 99
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
feat: Lv4 가사 검색, 무지의 먹방 라이브 풀이 추가 #113
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
level-4/무지의-먹방-라이브.js
Outdated
} | ||
|
||
// 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.
의미가 더 명확해지는 것 같네요 👍👍
level-4/무지의-먹방-라이브.js
Outdated
|
||
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.
원래 이 코드가 파이썬의 "큐"를 사용한 풀이였는데, 자바스크립트로 작성하면서 큐를 스택으로 전환해서 풀이하게 됐어요. 그러다보니 의도적으로 스택을 뒤집었습니다 ㅎㅎ
만약 스택 데이터를 유지시켜야 하는 경우라면 말씀대로 복사본을 생성하는 것이 맞습니다!!
level-4/무지의-먹방-라이브.js
Outdated
|
||
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
기존 풀이에 추가한 풀이
관련 이슈