전체 글851 숫자의 표현 package programmers; public class 숫자의표현 { public static int solution(int n) { int[] sum = new int[n + 1]; sum[0] = 0; for (int i = 1; i 2022. 12. 30. 이진 변환 반복하기 package programmers; import java.math.BigInteger; import java.util.Arrays; public class 이진변환반복하기 { public static int[] solution(String s) { StringBuilder sb; int zeroCount = 0; int binaryCount = 0; BigInteger bigInteger = new BigInteger(s); while ((bigInteger.compareTo(new BigInteger("1"))) > 0) { binaryCount++; sb = new StringBuilder(); for (int i = 0; i < s.length(); i++) { if (s.charAt(i) == .. 2022. 12. 29. 올바른 괄호 package programmers; import java.util.Stack; public class 올바른괄호 { static boolean solution(String s) { Stack stack = new Stack(); if (s.charAt(0) == ')') { return false; } for (int i = 0; i 0) { return false; } return true; } public static void main(Stri.. 2022. 12. 28. 최솟값 만들기 package programmers; import java.util.Collections; import java.util.PriorityQueue; public class 최솟값만들기 { public static int solution(int[] A, int[] B) { int ans = 0; PriorityQueue a = new PriorityQueue(); PriorityQueue b = new PriorityQueue(Collections.reverseOrder()); for (int i = 0; i < A.length; i++) { a.add(A[i]); b.add(B[i]); } while (!a.isEmpty()) { ans += a.poll() * b.poll(); } return ans;.. 2022. 12. 27. JadenCase 문자열 만들기 package programmers; import java.util.StringTokenizer; public class JadenCase문자열만들기 { // 모든 단어의 첫 문자는 대문자 // 그 외에 알파벳은 소문자 public static String solution(String s) { StringTokenizer st = new StringTokenizer(s, " ", true); StringBuilder sb = new StringBuilder(); while (st.hasMoreTokens()) { String str = st.nextToken(); if (str.startsWith(" ")) { sb.append(str); continue; } if (isStartWithNumber(st.. 2022. 12. 26. 최대값과 최솟값 package programmers; public class 최대값과최솟값 { public static String solution(String s) { String[] strings = s.split(" "); int max = Integer.MIN_VALUE; int min = Integer.MAX_VALUE; for (String string : strings) { int number = Integer.parseInt(string); max = Math.max(max, number); min = Math.min(min, number); } return min + " " + max; } public static void main(String[] args) { System.out.println(solu.. 2022. 12. 25. 이전 1 ··· 38 39 40 41 42 43 44 ··· 142 다음