본문 바로가기

verdantjuly/코딩테스트

(131)
프로그래머스 코딩테스트 연습 : 개인정보 수집 유효기간 (20240316, java) 문제 바로가기: https://school.programmers.co.kr/learn/courses/30/lessons/150370 나의 풀이 import java.util.*; import java.text.*; class Solution { public int[] solution(String today, String[] terms, String[] privacies) { List answer = new ArrayList(); try{ SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); String parsedToday = today.replace(".","/"); parsedToday = parsedToday + " 00..
프로그래머스 코딩테스트 연습 : 숫자 짝꿍 (20240315, java) 문제 바로가기: https://school.programmers.co.kr/learn/courses/30/lessons/131128 나의 풀이 FAIL import java.util.*; class Solution { public String solution(String X, String Y) { List XList = new ArrayList(Arrays.asList(X.split(""))); List YList = new ArrayList(Arrays.asList(Y.split(""))); List resultArray = new ArrayList(); for(int i =0; i
프로그래머스 코딩테스트 연습 : 옹알이(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