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

Inflearn Community Q&A

학생1's profile image
학생1

asked

Introduction to Javascript Algorithm Problem Solving (Coding Test Preparation)

4. Insertion sort

풀이 리뷰 부탁드립니다

Written on

·

153

0

 function solution(arr){
        let answer=arr;
        for (let i=1i<arr.lengthi++){
          let idx = i;
          for (let j=i-1j>=0j--){
            if (arr[idx] < arr[j]) {
              [arr[idx], arr[j]] = [arr[j], arr[idx]];
              idx = j;
            }
          }
        }
        return answer;
     }
삽입정렬javascript코테 준비 같이 해요!

Answer 1

0

codingcamp님의 프로필 이미지
codingcamp
Instructor

안녕하세요^^

네. 이렇게 해도 괜찮아 보입니다. 하지만 영상에서 구현한 방법도 알아두시기 바랍니다.

학생1님의 프로필 이미지
학생1
Questioner

답변 감사드립니다!

학생1's profile image
학생1

asked

Ask a question