다음에 올 숫자
/* 다음에 올 숫자 * 등차수열 혹은 등비수열 common이 매개변수로 주어질 때, * 마지막 원소 다음으로 올 숫자를 return * * common result * [1, 2, 3, 4] 5 * [2, 4, 8] 16 */ 123456789101112131415161718192021222324252627public class programmer_0_2 { static int[] input1 = {1,2,3,4}; static int[] input2 = {2,4,8}; static int[] input3 = {-60,0,60}; public int solution(int[] common) { int answer = 0; int inputAr = common.length; if(common[1] - c..
연속된 수의 합
/* 연속된 수의 합 연속된 세 개의 정수를 더해 12가 되는 경우는 3, 4, 5입니다. 두 정수 num과 total이 주어집니다. 연속된 수 num개를 더한 값이 total이 될 때, 정수 배열을 오름차순으로 담아 return하도록 solution함수를 완성해보세요. num total result 3 12 [3, 4, 5] 5 15 [1, 2, 3, 4, 5] 4 14 [2, 3, 4, 5] 5 5 [-1, 0, 1, 2, 3] num = 3, total = 12인 경우 [3, 4, 5]를 return합니다. num = 5, total = 15인 경우 [1, 2, 3, 4, 5]를 return합니다. 4개의 연속된 수를 더해 14가 되는 경우는 2, 3, 4, 5입니다. */ 1234567891011..