➜ 코딩 테스트/프로그래머스

프로그래머스 - 마지막 두 원소

class Solution { public static int[] solution(int[] num_list) { int[] result = new int[0]; if(num_list.length > 1) { int last = num_list[num_list.length - 1]; int prev = num_list[num_list.length - 2]; if (last > prev) { result = new int[num_list.length + 1]; System.arraycopy(num_list, 0, result, 0, num_list.length); result[num_list.length] = last - prev; } else { result = new int[num_list.length..

➜ 코딩 테스트/프로그래머스

프로그래머스 - n보다 커질 때까지 더하기

class Solution { public int solution(int[] numbers, int n) { int answer = 0; int sum = 0; for(int i = 0; i n){ answer = sum; break; } } return answer; } }

➜ 코딩 테스트/프로그래머스

프로그래머스 - 문자열로 변환

class Solution { public String solution(int n) { String answer = ""; answer = Integer.toString(n); return answer; } }

➜ 코딩 테스트/프로그래머스

프로그래머스 - 부분 문자열인지 확인하기

class Solution { public int solution(String my_string, String target) { if(my_string.contains(target)) { return 1; }else{ return 0; } } }

➜ 코딩 테스트/프로그래머스

프로그래머스 - 문자열을 정수로 변환하기

class Solution { public int solution(String n_str) { return Integer.parseInt(n_str); } }

➜ 코딩 테스트/프로그래머스

프로그래머스 - 조건에 맞게 수열 변환하기 1

class Solution { public int[] solution(int[] arr) { int[] answer = new int[arr.length]; for(int i = 0; i = 50 && arr[i] % 2 == 0 ){ answer[i] = arr[i] / 2; }else if( arr[i] 50 && arr[i] % 2 == 1){ answer[i] = arr[i]; } } return answer; } }

➜ 코딩 테스트/프로그래머스

프로그래머스 - 이어 붙인 수

class Solution { public int solution(int[] num_list) { String odd = ""; String even = ""; int intodd = 0; int inteven = 0; for(int i = 0; i < num_list.length; i++){ if(num_list[i] % 2 == 1){ odd += num_list[i]; }else if (num_list[i] % 2 == 0){ even += num_list[i]; } } intodd = Integer.parseInt(odd); inteven = Integer.parseInt(even); return intodd + inteven; } }

➜ 코딩 테스트/프로그래머스

프로그래머스 - 원소들의 곱과 합

class Solution { public int solution(int[] num_list) { int sum = 0; int mul = 1; for(int i = 0; i mul){ return 1; }else{ return 0; } } }

➜ 코딩 테스트/프로그래머스

프로그래머스 - 주사위 게임 2

class Solution { public int solution(int a, int b, int c) { if (a == b && b == c) { return (a + b + c) * (a * a + b * b + c * c) * (a * a * a + b * b * b + c * c * c); } else if (a == b || b == c || c == a) { return (a + b + c) * (a * a + b * b + c * c); } else { return a + b + c; } } }

➜ 코딩 테스트/프로그래머스

프로그래머스 - 등차수열의 특정한 항만 더하기

class Solution { public int solution(int a, int d, boolean[] included) { int answer = 0; int[] arr = new int[included.length]; arr[0] = a; for(int i = 0; i = 1) { arr[i] = arr[i - 1] + d; } if(included[i]){ answer += arr[i]; } } return answer; } }

강맹석
'➜ 코딩 테스트/프로그래머스' 카테고리의 글 목록 (31 Page)