Algorithm
-
[프로그래머스] K번째수Algorithm 2021. 1. 18. 23:43
programmers.co.kr/learn/courses/30/lessons/42748 코딩테스트 연습 - K번째수 [1, 5, 2, 6, 3, 7, 4] [[2, 5, 3], [4, 4, 1], [1, 7, 3]] [5, 6, 3] programmers.co.kr 더보기 문제 설명 배열 array의 i번째 숫자부터 j번째 숫자까지 자르고 정렬했을 때, k번째에 있는 수를 구하려 합니다. 예를 들어 array가 [1, 5, 2, 6, 3, 7, 4], i = 2, j = 5, k = 3이라면 1. array의 2번째부터 5번째까지 자르면 [5, 2, 6, 3]입니다. 2. 1에서 나온 배열을 정렬하면 [2, 3, 5, 6]입니다. 3. 2에서 나온 배열의 3번째 숫자는 5입니다. 배열 array, [i,..
-
[프로그래머스] 소수 찾기Algorithm 2021. 1. 18. 22:03
programmers.co.kr/learn/courses/30/lessons/12921 코딩테스트 연습 - 소수 찾기 1부터 입력받은 숫자 n 사이에 있는 소수의 개수를 반환하는 함수, solution을 만들어 보세요. 소수는 1과 자기 자신으로만 나누어지는 수를 의미합니다. (1은 소수가 아닙니다.) 제한 조건 n은 2이상 programmers.co.kr 더보기 문제 설명 1부터 입력받은 숫자 n 사이에 있는 소수의 개수를 반환하는 함수, solution을 만들어 보세요. 소수는 1과 자기 자신으로만 나누어지는 수를 의미합니다. (1은 소수가 아닙니다.) 제한 조건 - n은 2이상 1000000이하의 자연수입니다. 입출력 예 n result 10 4 5 3 풀이 function solution(n) {..
-
[프로그래머스] 약수의 합Algorithm 2021. 1. 18. 21:12
programmers.co.kr/learn/courses/30/lessons/12928 코딩테스트 연습 - 약수의 합 정수 n을 입력받아 n의 약수를 모두 더한 값을 리턴하는 함수, solution을 완성해주세요. 제한 사항 n은 0 이상 3000이하인 정수입니다. 입출력 예 n return 12 28 5 6 입출력 예 설명 입출력 예 #1 12의 약수 programmers.co.kr 더보기 문제 설명 정수 n을 입력받아 n의 약수를 모두 더한 값을 리턴하는 함수, solution을 완성해주세요. 제한 사항 - n은 0 이상 3000이하인 정수입니다 입출력 예 n return 12 28 5 6 수도코드 1부터 입력받은 숫자까지 순서대로 입력받은 수에서 나누어떨어지는 숫자를 순서대로 더한다. 반복문 끝나면..
-
[Codewars] Valid BracesAlgorithm 2020. 11. 16. 23:53
www.codewars.com/kata/5277c8a221e209d3f6000b56/train/javascript Codewars: Achieve mastery through challenge Codewars is where developers achieve code mastery through challenge. Train on kata in the dojo and reach your highest potential. www.codewars.com 더보기 Write a function that takes a string of braces, and determines if the order of the braces is valid. It should return true if the string is v..
-
[Codewars] Format a string of names like 'Bart, Lisa & Maggie'Algorithm 2020. 11. 8. 18:31
Format a string of names like 'Bart, Lisa & Maggie' 문제 www.codewars.com/kata/53368a47e38700bd8300030d/train/javascript Codewars: Achieve mastery through challenge Codewars is where developers achieve code mastery through challenge. Train on kata in the dojo and reach your highest potential. www.codewars.com [문제] Format a string of names like 'Bart, Lisa & Maggie' Given: an array containing hashe..
-
[Codewars] Are they the "same"?Algorithm 2020. 11. 8. 17:31
www.codewars.com/kata/550498447451fbbd7600041c/train/javascript Codewars: Achieve mastery through challenge Codewars is where developers achieve code mastery through challenge. Train on kata in the dojo and reach your highest potential. www.codewars.com 더보기 문제 Given two arrays a and b write a function comp(a, b) (or compSame(a, b)) that checks whether the two arrays have the "same" elements, wit..