• 카테고리

    질문 & 답변
  • 세부 분야

    알고리즘 · 자료구조

  • 해결 여부

    미해결

역시나 좌측으로 Special Sort 되고 있습니다...

22.03.29 17:38 작성 조회수 102

0

function specialBubbleSort([length, numbers]) {
    const nums = [...numbers];
    for (let idx = 1; idx < length; idx++) {
        for (let jdx = idx; jdx > 0; jdx--) {
            if (nums[jdx] < 0 && nums[jdx-1] >= 0) [nums[jdx-1], nums[jdx]] = [nums[jdx], nums[jdx-1]]
        }
    }
    return nums;
}

답변 0

답변을 작성해보세요.

답변을 기다리고 있는 질문이에요.
첫번째 답변을 남겨보세요!