본문 바로가기

Coding Test

(221)
[프로그래머스/자바] 아이스 아메리카노 class Solution { public int[] solution(int money) { int[] answer = {money/5500, money%5500}; return answer; } }
[프로그래머스/자바] 특정 문자 제거하기 class Solution { public String solution(String my_string, String letter) { return my_string.replace(letter, ""); } }
[프로그래머스/자바] 최댓값 만들기 import java.util.*; class Solution { public int solution(int[] numbers) { Arrays.sort(numbers); return numbers[numbers.length-1]*numbers[numbers.length-2]; } }
[프로그래머스/자바] 중앙값 구하기 import java.util.Arrays; class Solution { public int solution(int[] array) { Arrays.sort(array); return array[array.length/2]; } }
[프로그래머스/자바] 배열 자르기 class Solution { public int[] solution(int[] numbers, int num1, int num2) { int[] answer = new int[num2 - num1 + 1]; int index = 0; for(int i=num1; i
[프로그래머스/자바] 머쓱이보다 키 큰 사람 class Solution { public int solution(int[] array, int height) { int answer = 0; for(int num : array) { if(num > height) answer ++; } return answer; } } import java.util.Arrays; class Solution { public int solution(int[] array, int height) { return (int) Arrays.stream(array).filter(value -> value > height).count(); } }
[프로그래머스/자바] 짝수 홀수 개수 class Solution { public int[] solution(int[] num_list) { int[] answer = {0, 0}; for(int num : num_list){ if(num%2 == 0){ answer[0] = answer[0] + 1; } else { answer[1] = answer[1] + 1; } } return answer; } }
[프로그래머스/자바] 배열 뒤집기 class Solution { public int[] solution(int[] num_list) { int[] list = new int[num_list.length]; for(int i=0; i