Java 프로그래머스 코딩테스트 입문 Day 14 조건문, 반복문, 시뮬레이션, 문자열
·
📌Back-End/프로그래머스
가까운 수  import java.util.Arrays;/** * 코딩테스트 입문 Day 14 조건문, 반복문, 시뮬레이션, 문자열 * 가까운 수 */public class Main1 { public static void main(String[] args) { System.out.println(solution(new int[]{3, 10, 28}, 20)); System.out.println(solution(new int[]{10, 11, 12}, 13)); } public static int solution(int[] array, int n) { int answer = 0; Arrays.sort(array); for (i..
Java 프로그래머스 코딩테스트 입문 Day 13 문자열, 배열, 사칙연산, 수학, 조건문
·
📌Back-End/프로그래머스
컨트롤 제트  import java.util.LinkedList;/** * 코딩테스트 입문 Day 13 문자열, 배열, 사칙연산, 수학, 조건문 * 컨트롤 제트 */public class Main1 { public static void main(String[] args) { System.out.println(solution("1 2 Z 3")); System.out.println(solution("10 20 30 40")); System.out.println(solution("10 Z 20 Z 1")); System.out.println(solution("10 Z 20 Z")); System.out.println(solution("-1 ..
Java 프로그래머스 코딩테스트 입문 Day 12 문자열, 정렬, 사칙연산, 수학
·
📌Back-End/프로그래머스
모음 제거  /** * 코딩테스트 입문 Day 12 문자열, 정렬, 사칙연산, 수학 * 모음 제거 */public class Main1 { public static void main(String[] args) { System.out.println(solution("bus")); System.out.println(solution("nice to meet you")); } public static String solution(String my_string) { return my_string.replaceAll("[aeiou]", ""); }}  문자열 정렬하기 (1)  import java.util.Comparator;import java.util...
Java 프로그래머스 코딩테스트 입문 Day 11 수학, 반복문
·
📌Back-End/프로그래머스
주사위의 개수  /** * 코딩테스트 입문 Day 11 수학, 반복문 * 주사위의 개수 */public class Main1 { public static void main(String[] args) { System.out.println(solution(new int[]{1, 1, 1}, 1)); System.out.println(solution(new int[]{10, 8, 6}, 3)); } public static int solution(int[] box, int n) { return (box[0] / n) * (box[1] / n) * (box[2] / n); }}  합성수 찾기  /** * 코딩테스트 입문 Day 11 수학, 반복문 * 합..
Java 프로그래머스 코딩테스트 입문 Day 10 조건문, 배열, 수학, 시뮬레이션
·
📌Back-End/프로그래머스
점의 위치 구하기  /** * 코딩테스트 입문 Day 10 조건문, 배열, 수학, 시뮬레이션 * 점의 위치 구하기 */public class Main1 { public static void main(String[] args) { System.out.println(solution(new int[]{2, 4})); System.out.println(solution(new int[]{-7, 9})); } public static int solution(int[] dot) { int answer = 0; if (dot[0] > 0 && dot[1] > 0) { answer = 1; } else if (dot[0] ..
Java 프로그래머스 코딩테스트 입문 Day 9 수학, 문자열, 해시, 완전탐색, 조건문
·
📌Back-End/프로그래머스
개미 군단  /** * 코딩테스트 입문 Day 9 수학, 문자열, 해시, 완전탐색, 조건문 * 개미 군단 */public class Main1 { public static void main(String[] args) { System.out.println(solution(23)); System.out.println(solution(24)); System.out.println(solution(999)); } public static int solution(int hp) { int answer = 0; int general = 5; int soldier = 3; int worker = 1; wh..
Java 프로그래머스 코딩테스트 입문 Day 8 배열, 구현, 수학
·
📌Back-End/프로그래머스
배열 자르기  /** * 코딩테스트 입문 Day 8 배열, 구현, 수학 * 배열 자르기 */public class Main1 { public static void main(String[] args) { int[] result = solution(new int[]{1, 2, 3, 4, 5}, 1, 3); for (int num : result) { System.out.print(num + " "); } System.out.println(); result = solution(new int[]{1, 3, 5}, 1, 2); for (int num : result) { System.out.pr..
Java 프로그래머스 코딩테스트 입문 Day 7 문자열, 조건문, 수학, 반복문
·
📌Back-End/프로그래머스
특정 문자 제거하기  /** * 코딩테스트 입문 Day 7 문자열, 조건문, 수학, 반복문 * 특정 문자 제거하기 */public class Main1 { public static void main(String[] args) { System.out.println(solution("abcdef", "f")); System.out.println(solution("BCBdbe", "B")); } public static String solution(String my_string, String letter) { return my_string.replace(letter, ""); }}  각도기  /** * 코딩테스트 입문 Day 7 문자열, 조건문, 수학..
Java 프로그래머스 코딩테스트 입문 Day 6 문자열, 반복문, 출력, 배열, 조건문
·
📌Back-End/프로그래머스
문자열 뒤집기  /** * 코딩테스트 입문 Day 6 문자열, 반복문, 출력, 배열, 조건문 * 문자열 뒤집기 */public class Main1 { public static void main(String[] args) { System.out.println(solution("jaron")); System.out.println(solution("bread")); } public static String solution(String my_string) { StringBuilder sb = new StringBuilder(my_string); return sb.reverse().toString(); }}  직각삼각형 출력하기  impor..
Java 프로그래머스 코딩테스트 입문 Day 5 수학, 배열
·
📌Back-End/프로그래머스
옷가게 할인 받기  /** * 코딩테스트 입문 Day 5 수학, 배열 * 옷가게 할인 받기 */public class Main1 { public static void main(String[] args) { System.out.println(solution(150000)); System.out.println(solution(580000)); } public static int solution(int price) { if (price >= 500_000) { price = (int) (price * 0.8); } else if (price >= 300_000) { price = (int) (price *..
Java 프로그래머스 코딩테스트 입문 Day 4 수학, 배열
·
📌Back-End/프로그래머스
피자 나눠 먹기 (1)  /** * 코딩테스트 입문 Day 4 수학, 배열 * 피자 나눠 먹기 (1) */public class Main1 { public static void main(String[] args) { System.out.println(solution(7)); System.out.println(solution(1)); System.out.println(solution(15)); } public static int solution(int n) { double pizza = (double) n / (double) 7; return pizza   피자 나눠 먹기 (2)  /** * 코딩테스트 입문 Day 4 수학, 배..
Java 프로그래머스 코딩테스트 입문 Day 3 사칙연산, 배열, 수학
·
📌Back-End/프로그래머스
나머지 구하기  /** * 코딩테스트 입문 Day 3 사칙연산, 배열, 수학 * 나머지 구하기 */public class Main1 { public static void main(String[] args) { System.out.println(solution(3, 2)); System.out.println(solution(10, 5)); } public static int solution(int num1, int num2) { return num1 % num2; }}  중앙값 구하기  import java.util.stream.IntStream;/** * 코딩테스트 입문 Day 3 사칙연산, 배열, 수학 * 중앙값 구하기 */public clas..
구 일
'분류 전체보기' 카테고리의 글 목록 (2 Page)