Java606 [프로그래머스/Java] 2개 이하로 다른 비트 -Codeclass Solution { public long[] solution(long[] numbers) { long[] answer = new long[numbers.length]; for (int i = 0; i = 0; i--) { if (checkBin.charAt(i) == '0') { zeroIdx = i; break; } } // 0을 1로 바꾸고 이전 비트의 값을 0으로 변경 StringBuilder sb = new StringBuilder(); for (int i = 0; i 처음에 반복문으로 찾으려 했으나 시간 .. 2026. 4. 6. [백준/Java] 24035번 Impartial Offerings -Codeimport java.io.*;import java.util.*;public class BOJ24035 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int testCase = Integer.parseInt(br.readLine()); Map sizeCntMap = new HashMap(); for (int test = 1; test sizeSet = new TreeSet(Comparator.naturalOrder()).. 2026. 4. 6. [프로그래머스/Java] 삼각 달팽이 -Codeclass Solution { // 3개의 방향 셋팅 static int[] dRow = {1, 0, -1}; static int[] dCol = {0, 1, -1}; public int[] solution(int n) { // 총 사용 숫자 범위 int total = (n * (n + 1)) / 2; int[][] board = new int[n][n]; // 위치 보정을 위한 -1, 시작 숫자 지정 int row = -1, col = 0, num = 1; for (int i = 0; i 처음에는 이동 방향을 셋팅하고 배열의 끝에 도달하거나 하면 값을 변경하면서 이동 방향을 수정하려 했으나 잘 안됐.. 2026. 4. 5. [백준/Java] 33904번 삼각형 -Codeimport java.io.*;import java.util.*;public class BOJ1925 { static class Pos { long x, y; public Pos(long x, long y) { this.x = x; this.y = y; } } public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); Pos[] tri = new Pos[3]; for.. 2026. 4. 5. [프로그래머스/Java] 오픈채팅방 -Codeimport java.util.*;class Solution { static class Member { String id; boolean exit; public Member(String id, boolean exit) { this.id = id; this.exit = exit; } } public String[] solution(String[] record) { Map idAndName = new HashMap(); List log = new ArrayList(); for (String line : record) { String.. 2026. 4. 5. [백준/Java] 33904번 불필요한 for문 -Codeimport java.io.*;import java.util.*;public class BOJ33904 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); List lines = new ArrayList(); // 라인이 ioe 전까지 담기 String line; while ((line = br.readLine()) != null) { lines.add(line); } .. 2026. 4. 4. 이전 1 2 3 4 ··· 101 다음