본문 바로가기

분류 전체보기50

[항해99클럽] Java 비기너_Day 20 CD 오늘의 문제 >> https://www.acmicpc.net/problem/4158 [ 생각 흐름 ]N, M 개수만큼 작성되는 숫자를 배열을 만들고두 배열에 공통된 요소의 개수를 세면 되지 않을까? [ Java ] import java.io.*;import java.util.*;public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); while (true) { StringTokenizer st = new StringTokeni.. 2025. 4. 26.
[항해99클럽] Java 비기너_Day 19 Sort 마스터 배지훈의 후계자 오늘의 문제 >> https://www.acmicpc.net/problem/20551 [ 생각 흐름 ]먼저 배열 A를 정렬해서 B를 만들고 이진탐색으로 찾으면 되겠다~ [ Java ]import java.util.*;public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int M = sc.nextInt(); int[] A = new int[N]; for(int i=0; i 2025. 4. 24.
[항해99클럽] Java 비기너_Day 18 캠프가는 영식 오늘의 문제 >> https://www.acmicpc.net/problem/1590 [ 생각 흐름 ]버스 개수만큼 반복하면서 최소 대기시간을 계산해야 될 것 같다~ [ Java ]import java.util.*;public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int T = sc.nextInt(); int waitTime = Integer.MAX_VALUE; for(int i=0; i= T){ waitTime = Math.min.. 2025. 4. 23.
[항해99클럽] Java 비기너_Day 17 Find the Distance Value Between Two Arrays 오늘의 문제 >> https://leetcode.com/problems/find-the-distance-value-between-two-arrays/description/ [ 생각 흐름 ]이중 for문으로 돌면서 조건 확인해서 개수를 세면 되겠다~ [ Java ] class Solution { public int findTheDistanceValue(int[] arr1, int[] arr2, int d) { int answer = 0; for(int num1:arr1){ boolean isTarget = true; for(int num2:arr2){ if (Math.abs(num1-num2) Java에서 절댓.. 2025. 4. 22.
[항해99클럽] Java 비기너_Day 16 Intersection of Two Arrays 오늘의 문제 >> https://leetcode.com/problems/intersection-of-two-arrays/description/ [ 생각 흐름 ]일단 각 배열을 Set으로 만들어서 중복 제거하고,두개 다 속하는 원소만 리스트로 만들면 될 것 같다..! [ Java ]class Solution { public int[] intersection(int[] nums1, int[] nums2) { Set set1 = new HashSet(); for(int num: nums1){ set1.add(num); } Set resultSet = new HashSet(); for(int num:nums2){ .. 2025. 4. 21.
[항해99클럽] Java 비기너_Day 15 학생 인기도 측정 오늘의 문제 >> https://www.acmicpc.net/problem/25325 [ 생각 흐름 ]이름을 먼저 HashMap에 담아놓고for문을 돌면서 이름별로 카운트를 하면 되지 않을까? [ JAVA ] import java.util.*;public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); sc.nextLine(); String students = sc.nextLine(); String[] studentsArr = students.split(" "); Map co.. 2025. 4. 18.