본문 바로가기

verdantjuly

(341)
프로그래머스 코딩테스트 연습 : 옹알이(2) (20240315, java) 문제 바로가기: https://school.programmers.co.kr/learn/courses/30/lessons/133499 나의 풀이 FAIL class Solution { public int solution(String[] babbling) { int count = 0; for(String word : babbling){ String wordCheck = word; wordCheck = wordCheck.replaceAll("aya",""); wordCheck = wordCheck.replaceAll("ye",""); wordCheck = wordCheck.replaceAll("woo",""); wordCheck = wordCheck.replaceAll("ma",""); word = word...
프로그래머스 코딩테스트 연습 : 로또의 최고 순위와 최저 순위 (20240315, java) 문제 바로가기: https://school.programmers.co.kr/learn/courses/30/lessons/77484 나의 풀이 import java.util.*; // GPT의 도움을 받아 품 class Solution { public int[] solution(int[] lottos, int[] win_nums) { // Remove zeros from lottos int zero = 0; Set notZeroSet = new HashSet(); for (int num : lottos) { if (num != 0) { notZeroSet.add(num); } else { zero++; } } // Count the matches int matches = 0; for (int num : w..
프로그래머스 코딩테스트 연습 : 3진법 뒤집기 (20240312, java) 문제 바로가기: https://school.programmers.co.kr/learn/courses/30/lessons/68935 나의 풀이 FAIL class Solution { public int solution(int n) { int left = n % 3 for (i=0; i 0){ a = (n % 3) + a; n /= 3; } a = new StringBuilder(a).reverse()...
프로그래머스 코딩테스트 연습 : 최대공약수와 최소공배수 (20240312, java) 문제 바로가기: https://school.programmers.co.kr/learn/courses/30/lessons/12940 나의 풀이 class Solution { public int[] solution(int n, int m) { int[] answer = new int[2]; for (int i=1; i0; j--){ if (n%j == 0 && m%j == 0){ answer[0] = j; break; } } return answer; } } 다른 사람의 풀이 class Solution { public int[] solution(int n, int m) { int[] answer = new int[2]; for (int i = 1; i < n + m; i++) { if (n % i == 0 ..
프로그래머스 코딩테스트 연습 : 직사각형 별찍기(20240312, java) 문제 바로가기: https://school.programmers.co.kr/learn/courses/30/lessons/12969 나의 풀이 import java.util.Scanner; class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); for (int i=0;i sb.append("*")); IntStream.range(0, b).forEach(s -> System.out.println(sb.toString())); } } 소감 StringBuilder append 기억하기
프로그래머스 코딩 테스트 연습 : 행렬의 덧셈 (20240312, java) 문제 바로가기: https://school.programmers.co.kr/learn/courses/30/lessons/12950 나의 풀이 class Solution { public int[][] solution(int[][] arr1, int[][] arr2) { int[][] arr3 = new int[arr1.length][arr1[0].length]; for(int i=0;i
프로그래머스 코딩테스트 연습 : 문자열 다루기 기본 (20240312, java) 문제 바로가기: https://school.programmers.co.kr/learn/courses/30/lessons/12918 나의 풀이 import java.util.*; class Solution { public boolean solution(String s) { String[] numbers = {"0","1","2","3","4","5","6","7","8","9"}; String[] array = s.split(""); if (s.length() == 4 || s.length() == 6){ for (int i=0; i
프로그래머스 코딩테스트 연습 : 부족한 금액 계산하기 (20240312, java) 문제 바로가기: https://school.programmers.co.kr/learn/courses/30/lessons/82612 나의 풀이 class Solution { public long solution(int price, int money, int count) { long wallet = money; for (long i=1; i= 0 ? 0 : -wallet; } } 다른 사람의 풀이 class Solution { public long solution(long price, long money, long count) { return Math.max(price * (count * (count + 1) / 2) - money, 0); } } 소감 여러가지 풀이가 있다