This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function solution(n){ | |
var answer = 0; | |
var arr = []; | |
for(var i = 2; i <= n; i++){ | |
arr[i] = i; | |
} | |
for(var i = 2; i <= n; i++){ | |
if(arr[i] == 0) continue; | |
for(var j = i + i; j <= n; j+=i){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function solution(n){ | |
var answer = 0; | |
for(var i = 2; i <= n; i++){ | |
var cnt = 0; | |
for(var j = 1; j <= i; j++){ | |
if(i % j == 0 && cnt < 3) | |
cnt++; | |
} | |
if(cnt == 2) answer++; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function solution(seoul){ | |
var answer = ''; | |
for(var i = 0; i < seoul.length; i++){ | |
if(seoul[i] === 'Kim'){ | |
answer = '김서방은 ' + i + '에 있다'; | |
break; | |
} | |
} | |
return answer; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function solution(s){ | |
var check = ""; | |
var pNum = 0, yNum = 0; | |
for(var i = 0; i < s.length; i++){ | |
check = s.charAt(i); | |
console.log(check); | |
if(check == 'p' || check == 'P'){ | |
pNum += 1; | |
} | |
else if(check == 'y' || check == 'Y'){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function solution(strings, n){ | |
return strings.sort(function(a, b){ | |
let front = a[n] | |
let back = b[n] | |
if( front === back){ | |
return (a > b) - (a < b) | |
} else{ | |
return (front > back) - (front < back) | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function solution(string, n){ | |
var answer = []; | |
var empt = [] | |
for(var i = 0; i < string.length; i++){ | |
empt[i] = string[i].charAt(n); | |
} | |
empt.sort(); | |
console.log(empt); | |
for(var i = 0 ; i < string.length; i++){ | |
for(var j = 0; j < empt.length; j++){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function solution(array, divisor){ | |
var answer = []; | |
for(var i = 0; i < array.length; i++){ | |
if(array[i] % divisor == 0){ | |
answer.push(array[i]); | |
} | |
} | |
if(answer == ""){answer.push(-1)} | |
return answer.sort(function(a,b){ return a - b}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function solution(arr){ | |
var answer = []; | |
var correct = 0; | |
for(var i = 0; i < arr.length; i++){ | |
if(arr[i] == arr[i+1]){ | |
continue; | |
} | |
else{ | |
answer.push(arr[i]); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function solution(array, commands){ | |
var answer = []; | |
var list; | |
for(var i = 0; i < commands.length; i++){ | |
var start = (commands[i][0] - 1); | |
var end = commands[i][1]; | |
list = array.slice(start, end).sort(function(a,b){ | |
return a-b; | |
}); | |
answer.push(list[commands[i][2] - 1]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function solution(n, lost, reserve){ | |
var answer = n - lost.length; | |
//reservePerson이 체육복을 도난 당했을 때 | |
for(var x = 0 ; x < reserve.length; x++){ | |
for(var y = 0; y < lost.length; y++){ | |
if(reserve[x] == -1 && lost[y] == -1){ | |
continue; | |
} | |
if(reserve[x] == lost[y]){ | |
reserve[x] = -1; |