본문 바로가기

Beakjoon&프로그래머스/Java466

[프로그래머스/Java] 콜라 문제 -Codeclass Solution { public int solution(int a, int b, int n) { int answer = 0; int temp; while (n >= a) { temp = n / a * b; answer += temp; n = temp + n % a; } return answer; }} 2025. 2. 26.
[프로그래머스/Java] 문자열 내 마음대로 정렬하기 -Codeimport java.util.*;class Solution { public String[] solution(String[] strings, int n) { return Arrays.stream(strings).sorted( Comparator.comparing((String el) -> el.charAt(n)) .thenComparing(Comparator.naturalOrder()) ).toArray(String[]::new); }} 2025. 2. 26.
[프로그래머스/Java] 푸드 파이트 대회 -Codeclass Solution { public String solution(int[] food) { StringBuilder answer = new StringBuilder(); int water = food[0] + 1; for (int i = 1; i 2025. 2. 26.
[프로그래머스/Java] 숫자 문자열과 영단어 -Codeimport java.util.List;class Solution { public int solution(String s) { List numStrings = List.of( "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" ); for (int i = 0; i 2025. 2. 25.
[프로그래머스/Java] 두 개 뽑아서 더하기 -Codeimport java.util.Arrays;import java.util.List;import java.util.ArrayList;import java.util.Collections;class Solution { public int[] solution(int[] numbers) { List answer = new ArrayList(); int numLen = numbers.length; for (int i = 0; i 2025. 2. 25.
[프로그래머스/Java] 가장 가까운 같은 글자 -Codeimport java.util.Arrays;import java.util.Map;import java.util.HashMap;class Solution { public int[] solution(String s) { int[] answer = new int[s.length()]; Map stringMap = new HashMap(); for (int i = 0; i 2025. 2. 25.