본문 바로가기

Coding Test/프로그래머스

(138)
[프로그래머스/자바] n의 배수 class Solution { public int solution(int num, int n) { return num % n == 0 ? 1 : 0; } }
[프로그래머스/자바] 모의고사 import java.util.ArrayList; import java.util.List; class Solution { public int[] solution(int[] answers) { int[] student1 = {1, 2, 3, 4, 5}; int[] student2 = {2, 1, 2, 3, 2, 4, 2, 5}; int[] student3 = {3, 3, 1, 1, 2, 2, 4, 4, 5, 5}; int[] score = {0, 0, 0}; for(int i=0; i
[프로그래머스/자바] 체육복 import java.util.HashSet; class Solution { public int solution(int n, int[] lost, int[] reserve) { HashSet reserveSet = new HashSet(); HashSet lostSet = new HashSet(); for(int l : lost) { lostSet.add(l); } for(int r : reserve) { if(lostSet.contains(r)) { lostSet.remove(r); } else { reserveSet.add(r); } } for (int i : reserveSet) { if (lostSet.contains(i - 1)) { lostSet.remove(i - 1); } else if (..
[프로그래머스/자바] 편지 class Solution { public int solution(String message) { return message.length() * 2; } }
[프로그래머스/자바] 배열 두 배 만들기 class Solution { public int[] solution(int[] numbers) { for(int i=0; i i * 2).toArray(); } }
[프로그래머스/자바] 아이스 아메리카노 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]; } }