본문 바로가기

Coding Test

(221)
[프로그래머스/자바] 피자 나눠 먹기(1) class Solution { public int solution(int n) { return n%7 > 0 ? n/7+1 : n/7; } } class Solution { public int solution(int n) { return (n + 6) / 7; } }
[프로그래머스/자바] 피자 나눠 먹기 (3) class Solution { public int solution(int slice, int n) { int answer = n/slice; if(n%slice >= 1){ answer ++; } return answer; } } class Solution { public int solution(int slice, int n) { return n % slice > 0 ? n/slice+1 : n/slice; } }
[프로그래머스/자바] 문자열 내 마음대로 정렬하기 import java.util.*; class Solution { public String[] solution(String[] strings, int n) { Arrays.sort(strings); String[] result = new String[strings.length]; for(int i=0; i< strings.length; i++){ result[i] = strings[i].substring(n, n+1); } Arrays.sort(result); List list = new ArrayList(Arrays.asList(strings)); for(int i=0; i
[프로그래머스/자바] 가장 가까운 같은 글자 import java.util.Map; import java.util.HashMap; class Solution { public int[] solution(String s) { int[] answer = new int[s.length()]; Map map = new HashMap(); String[] arr = s.split(""); for(int i=0; i
[프로그래머스/자바] 신고 결과 받기 import java.util.*; class Solution { public int[] solution(String[] id_list, String[] report, int k) { Set set = new HashSet(); for(String names : report){ set.add(names); } Map map = new HashMap(); String[] reporter = new String[set.size()]; String[] reportee = new String[set.size()]; int index = 0; Iterator iter = set.iterator(); while(iter.hasNext()){ String[] names = iter.next().toString().s..
[프로그래머스/자바] [1차] 비밀지도 class Solution { public String[] solution(int n, int[] arr1, int[] arr2) { String[] answer = new String[n]; for(int i=0; i
[프로그래머스/자바] 완주하지 못한 선수 import java.util.Arrays; class Solution { public String solution(String[] participant, String[] completion) { Arrays.sort(participant); Arrays.sort(completion); for (int i=0; i
[프로그래머스/자바] 숫자 문자열과 영단어 class Solution { public int solution(String s) { String[] words = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"}; for(int i = 0; i < words.length; i++){ s = s.replace(words[i], Integer.toString(i)); } return Integer.parseInt(s); } }