전체 글


package practice; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String data = br.readLine(); if(Integer.parseInt(data)= 10) { sum = String.valueOf(Integer.parseInt(sum)%10); } data = datas[datas.le..


package practice; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; class Solution { public int[] solution(int n) { int[] answer = {}; int i = 2; ArrayList list = new ArrayList(); while (i


package practice; class Solution { public int solution(String my_string) { String[] arr = my_string.split(" "); int answer = Integer.parseInt(arr[0]); for (int i = 1; i < arr.length; i=i+2) { if(arr[i].equals("+")) { answer += Integer.parseInt(arr[i+1]); }else{ answer -= Integer.parseInt(arr[i+1]); } } return answer; } } public class Programmers { public static void main(String[] args) { String ..


package practice; import java.util.HashMap; class Solution { public String solution(String[] id_pw, String[][] db) { String answer = ""; HashMap map = new HashMap(); for (int i = 0; i < db.length ; i++) { map.put(db[i][0],db[i][1]); } for (int i = 0; i < map.size() ; i++) { if(!(map.containsKey(id_pw[0]))) { answer = "fail"; } else if (map.containsKey(id_pw[0]) && !(map.get(id_pw[0]).equals(id_p..


package practice; import java.util.ArrayList; import java.util.Arrays; class Solution { public int solution(String s) { int answer = 0; ArrayList list = new ArrayList(Arrays.asList(s.split(" "))); for (int i = 0; i < list.size(); i++) { if (list.get(i).equals("Z")) { list.remove(i); list.set(i-1,"0"); } } System.out.println(list); Integer[] answerArr = list.stream().mapToInt(Integer::parseInt).b..


package practice; import java.util.Arrays; import java.util.Collections; class Solution { public int[] solution(int[] emergency) { int[] answer = new int[emergency.length]; Integer[] array = Arrays.stream(emergency).boxed().toArray(Integer[]::new); Arrays.sort(array, Collections.reverseOrder()); for (int i = 0; i < emergency.length ; i++) { for (int j = 0; j < array.length ; j++) { if(emergency[..


package practice; class Solution { public int solution(int chicken) { int answer = 0; int coupon = chicken; while (coupon >= 10) { answer += coupon/10; coupon = coupon/10+coupon%10; } return answer; } } public class Programmers { public static void main(String[] args) { int chicken = 1081; System.out.println(new Solution().solution(chicken)); } } 이 문제에 핵심은 조건발동시 쿠폰을 계속 증가시켜주고, 쿠폰의 변동사항을 계속 반영하여야..


package practice; class Solution { public int[] solution(int num, int total) { int[] answer = new int[num]; int centerNum = total / num; // 4 int subNum = total % num == 0 ? num/2 : num/2-1; int startNum = centerNum - subNum; for (int i = 0; i < answer.length ; i++) { answer[i] = startNum+i; } return answer; } } public class Programmers { public static void main(String[] args) { int num = 5; int..