-
Notifications
You must be signed in to change notification settings - Fork 98
레벨 2 / 스킬트리 - feat: 풀이 추가 #112
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.
고생하셨습니다!! 코멘트는 참고용으로만 확인해주세요 😄
변경사항을 반영하고 싶다면, minkyeongJ의 main 브랜치에 변경사항을 push 하시면 됩니다!
아래의 참고사항을 모두 종합하면 아래와 같은 코드로도 가능합니다 👍
function solution(skill, skill_trees) { return skill_trees .map(tree => [...skill].map(s => { const num = [...tree].findIndex(t => t === s); return num < 0 ? 27 : num; }) ) .filter(c => c.every((v, i) => (i < c.length - 1 ? v <= c[i + 1] : true))).length; }
level-2/스킬트리&49993&.js
Outdated
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 skillArr = skill.split('')
level-2/스킬트리&49993&.js
Outdated
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-2/스킬트리&49993&.js
Outdated
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.
for 문 에서 if 조건에 해당하는 값을 발견하지 못했을 때 '27' 이라는 값을 push 하는 것이 목표였다면 아래와 같은 표현도 고려해보세요!
forEach 내에서 return은 다음 forEach 의 반복으로 가는 것을 의미합니다!
level-2/스킬트리&49993&.js
Outdated
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.
고차함수를 사용하면 코드가 조금 checkArr를 만드는 과정이 더 간결해질 수 있을 것 같습니다!!
아래와 같은 방법을 고려해보세요 😄
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-2/스킬트리&49993&.js
Outdated
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.
checkArr에서 오름차순인 것의 갯수를 찾는 것이 목적이라면 아래와 같은 방법도 고려해보세요!
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.
와,,, 정성스런 피드백 정말 감사합니다!! 피드백 내용 참고해서 수정하여 push 해보도록 하겠습니다!
새롭게 추가된 문제 풀이
기존 풀이에 추가한 풀이
레벨 2 / 스킬트리 17150a9
관련 이슈
새로운 방식의 풀이를 추가하였습니다.