Java613 [LeetCode/Java] 69. Sqrt(x) -Codeclass Solution { public int mySqrt(int x) { return (int) Math.sqrt(x); }} 2025. 11. 22. [LeetCode/Java] 67. Add Binary -Codeclass Solution { public String addBinary(String a, String b) { int aIndex = a.length() - 1; int bIndex = b.length() - 1; int now = 0; StringBuilder answer = new StringBuilder(); // 마지막 수부터 더하기 while (now > 0 || aIndex >= 0 || bIndex >= 0) { if (aIndex >= 0) { now += a.charAt(aIndex--) - '0'; } if (bIndex .. 2025. 11. 22. [백준/Java] 27445번 Gorani Command -Codeimport java.util.Scanner;public class BOJ27445 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int M = sc.nextInt(); int minY = Integer.MAX_VALUE; int yPos = 0; // y좌표 계싼 for (int i = 1; i 2025. 11. 22. [백준/Java] 34687번 라면 끓여 먹자 야호 -Codeimport java.util.Scanner;public class BOJ34687 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); System.out.println(m * 100 >= n * 81 ? "yaho" : "no"); }}처음에 0.81을 곱해서 했으나 부동 소수점 오차 때문에 위와 같이 해서 해결했습니다. 2025. 11. 21. [LeetCode/Java] 66. Plus One -Codeclass Solution { public int[] plusOne(int[] digits) { for (int i = digits.length - 1; i >= 0 ; i--) { digits[i]++; // 현제 인덱스 값이 10보다 작으면 바로 반환 if (digits[i] 문제를 이상하게 이해해서 어렵게 풀다가 문제점을 찾아보니 쉽게 해결했습니다. 2025. 11. 21. [LeetCode/Java] 58. Length of Last Word -Codeclass Solution { public int lengthOfLastWord(String s) { // 스페이스를 기준으로 나눠서 배열 생성 String[] strList = s.split(" "); // 리스트의 마지막 문자열 가져옴 String lastStr = strList[strList.length - 1]; // 마지막 문자열의 길이 반환 return lastStr.length(); }} 2025. 11. 20. 이전 1 ··· 82 83 84 85 86 87 88 ··· 103 다음