function insertSortLog(arr){ var n = arr.length-1 var unsorted = true var tmp = arr[n] var log = [] while(unsorted){ if(tmp < arr[n-1]) { arr[n] = arr[n-1] n-- } else { arr[n] = tmp unsorted = false } console.log(arr.join(' ')) } } function processData(input) { //Enter your code here input = input.split('\n') var n = input[0] var arr = input[1].split(' ') insertSortLog(arr) } process.stdin.resume(); process.stdin.setEncoding("ascii"); _input = ""; process.stdin.on("data", function (input) { _input += input; }); process.stdin.on("end", function () { processData(_input); });
공부합시다.
유일원칙 : 검색했을 떄 안나오는 것만을 작성한다.
2017년 9월 19일 화요일
Javascript Solution - Insertion Sort - Part 1
hackkerank Insertion Sort - Part 1
Javascript Solution - Intro to Tutorial Challenges
hackkerank Intro to Tutorial Challenges
function processData(input) { //Enter your code here input = input.split('\n') var V = input[0] var n = input[1] var ar = input[2].split(' ') console.log(ar.indexOf(V)) } process.stdin.resume(); process.stdin.setEncoding("ascii"); _input = ""; process.stdin.on("data", function (input) { _input += input; }); process.stdin.on("end", function () { processData(_input); });
피드 구독하기:
글 (Atom)