Java451 [프로그래머스/Java] 멀리 뛰기 -Codeclass Solution { public long solution(int n) { // 2이하는 n반환 if (n 2026. 1. 2. [프로그래머스/Java] 행렬의 곱셈 -Codeclass Solution { public int[][] solution(int[][] arr1, int[][] arr2) { // 결과로 반환할 배열 선언 int totalRow = arr1.length; int totalCol = arr2[0].length; int[][] answer = new int[totalRow][totalCol]; // 계산시 사용하는 arr1은 col부분, arr2는 row부분 횟수 int calcCnt = arr1[0].length; for (int row = 0; row 2026. 1. 2. [프로그래머스/Java] 구명보트 -Codeimport java.util.*;class Solution { public int solution(int[] people, int limit) { int answer = 0; // 순서대로 정렬 Arrays.sort(people); // 덱에 데이터 넣기 Deque dq = new ArrayDeque(); for (int person : people) { dq.addLast(person); } // 덱을 돌면서 확인 while(!dq.isEmpty()) { // 가장 무거운 사람 꺼내기 int heavy = dq.pol.. 2026. 1. 2. [백준/Java] 20733번 Triple Texting -Codeimport java.util.*;public class BOJ20733 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String str = sc.next(); // 문자열 길이 구하기 int divLength = str.length() / 3; // 3 덩이로 문자열 나누기 String first = str.substring(0, divLength); String second = str.substring(divLength, divLength * 2); String third = str.subs.. 2026. 1. 2. [프로그래머스/Java] 타겟 넘버 -Codeclass Solution { static int answer = 0; public int solution(int[] numbers, int target) { backtracking(0, 0, numbers, target); return answer; } private static void backtracking(int idx, int nowNum, int[] nums, int target) { int length = nums.length; if (idx == length) { if (nowNum == target) { answer++; } .. 2026. 1. 1. [LeetCode/Java] Max Number of K-Sum Pairs -Codeclass Solution { public int maxOperations(int[] nums, int k) { int answer = 0; // 투포인터 하기 위해 정렬 Arrays.sort(nums); // 왼쪽 오른쪽 커서 셋팅 int left = 0, right = nums.length - 1; // 왼쪽이 오른쪽 보다 작은 경우 반복 while (left k) { // k 보다 큰 경우 right-- right--; } else { // k 보다 작은 경우 left++ .. 2026. 1. 1. 이전 1 ··· 23 24 25 26 27 28 29 ··· 76 다음