인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

Inflearn Community Q&A

edwinpark's profile image
edwinpark

asked

Introduction to Javascript Algorithm Problem Solving (Coding Test Preparation)

5. Finding the rank

중첩반복문 해결

Resolved

Written on

·

264

0

const solution = (arr) => {
  let cnt = 1;
  let rankList = {};
  let sort = [...arr].sort((a, b) => b - a);
  sort.forEach(
    (point, idx) => 
        point !== sort[idx - 1] && (rankList[point] = cnt + idx));
  return arr.map((point) => rankList[point]);
};

중첩을 결하고자 위와 같이 풀어봤습니다. 평가를 부탁드립니다.

javascript코딩-테스트

Answer 1

0

codingcamp님의 프로필 이미지
codingcamp
Instructor

안녕하세요^^

네. 자바스크립트 답고 아이디어도 좋네요. 좋은 코드네요.

edwinpark's profile image
edwinpark

asked

Ask a question