문제 설명단어 s의 가운데 글자를 반환하는 함수, solution을 만들어 보세요. 단어의 길이가 짝수라면 가운데 두글자를 반환하면 됩니다.제한사항s는 길이가 1 이상, 100이하인 스트링입니다.s.substrs.substrings.charAtsmidsubstr()파라
프로그래머스 문제2. x만큼 간격이 있는 n개의 숫자 > 함수 solution은 정수 x와 자연수 n을 입력 받아, x부터 시작해 x씩 증가하는 숫자를 n개 지니는 리스트를 리턴해야 합니다. 다음 제한 조건을 보고, 조건을 만족하는 함수, solution을 완성해주세요
정수를 담고 있는 배열 arr의 평균값을 return하는 함수, solution을 완성해보세요.제한 조건arr은 길이 1 이상, 100 이하인 배열입니다.arr의 원소는 -10,000 이상 10,000 이하인 정수입니다.arr.reducereduce를 이렇게 사용하다니
1937년 Collatz란 사람에 의해 제기된 이 추측은, 주어진 수가 1이 될때까지 다음 작업을 반복하면, 모든 수를 1로 만들 수 있다는 추측입니다. 작업은 다음과 같습니다.1-1. 입력된 수가 짝수라면 2로 나눕니다. 1-2. 입력된 수가 홀수라면 3을 곱하고 1
프로그래머스 문제. 문자열 내 마음대로 정렬하기 > 문자열로 구성된 리스트 strings와, 정수 n이 주어졌을 때, 각 문자열의 인덱스 n번째 글자를 기준으로 오름차순 정렬하려 합니다. 예를 들어 strings가 ["sun", "bed", "car"]이고 n이 1이
배열 array의 i번째 숫자부터 j번째 숫자까지 자르고 정렬했을 때, k번째에 있는 수를 구하려 합니다.예를 들어 array가 1, 5, 2, 6, 3, 7, 4, i = 2, j = 5, k = 3이라면array의 2번째부터 5번째까지 자르면 5, 2, 6, 3입니
프로그래머스 문제 체육복 > 점심시간에 도둑이 들어, 일부 학생이 체육복을 도난당했습니다. 다행히 여벌 체육복이 있는 학생이 이들에게 체육복을 빌려주려 합니다. 학생들의 번호는 체격 순으로 매겨져 있어, 바로 앞번호의 학생이나 바로 뒷번호의 학생에게만 체육복을 빌려줄
괄호가 바르게 짝지어졌다는 것은 '(' 문자로 열렸으면 반드시 짝지어서 ')' 문자로 닫혀야 한다는 뜻입니다. 예를 들어"()()" 또는 "(())()" 는 올바른 괄호입니다.")()(" 또는 "(()(" 는 올바르지 않은 괄호입니다.'(' 또는 ')' 로만 이루어진
재귀함수의 형태로 작성하라입력받은 배열은 함수의 호출 뒤에도 처음 상태를 유지해야 한다.1)2)
N명의 학생의 발표순서가 될 수 있는 경우의 수가 차례대로 정렬되어 있다면, K의 발표 순서가 몇 번째 경우의 수인지를 답하라오늘의 TIL은 재귀함수였다. 위의 코드는 for가 3번이나 중첩된다. 위의 작성된 코드는 간결하지도 않고, 이해하기도 힘들다.오늘 배운 재귀함
n명이 입국심사를 위해 줄을 서서 기다리고 있습니다. 각 입국심사대에 있는 심사관마다 심사하는데 걸리는 시간은 다릅니다.처음에 모든 심사대는 비어있습니다. 한 심사대에서는 동시에 한 명만 심사를 할 수 있습니다. 가장 앞에 서 있는 사람은 비어 있는 심사대로 가서 심사
두 개의 배열(base, sample)을 입력받아 sample이 base의 부분집합인지 여부를 리턴해야 합니다.처음 이 문제를 풀었을 때 base, sample 배열을 for문으로 하나씩 돌며 sample의 element를 모두 포함하고 있는지 확인하였다. 하지만 이렇
🖍 문제 1 문제 설명 세로 길이 2, 가로 길이 n인 2 x n 보드가 있습니다. 2 x 1 크기의 타일을 가지고 이 보드를 채우는 모든 경우의 수를 리턴해야 합니다. 입출력 예시 문제해결 1. 재귀함수 2. 피보나치 수열 적용 🖍 문제 2 멀리뛰기 문제
임의의 tree를 구성하는 노드 중 하나의 Node 객체를 입력받아, 해당 노드를 시작으로 깊이 우선 탐색(DFS, Depth First Search)을 합니다. 이 때, 탐색되는 순서대로 노드의 값이 저장된 배열을 리턴해야 합니다.위 코드에서 재귀함수를 사용하였는데,
출근한 직원에게 M, N과자를 각각 공평하게 나누어 줄 수 있는 경우의 수를 구하여라.answer = \[직원수, M과자, N과자] 해당 문제의 테스트케이스에는 divideChocolateStick(1000000000, 1000000000)가 있었기 때문에, 불필요한
2차원 M x N 배열을 나선형(spiral)으로 순회해야 합니다.
방금그곡 생각하지 못했던 테스트 케이스 1\. C 2. 시작의 분보다 끝나는 분이 작을 경우를 생각하고 코드를 작성!(13:20 , 14:00 ) 3\.