코테29 코딩테스트 입문 - Day 6 뒤집힌 문자열class Solution { public String solution(String my_string) { StringBuilder sb = new StringBuilder(); for(int i = my_string.length() - 1; i >= 0; i--){ sb.append(my_string.charAt(i)); } return sb.toString(); }}직각삼각형 출력하기import java.util.Scanner;public class Solution { public static void main(String[] args) { Scanner sc = new Sca.. 2025. 4. 12. 코딩테스트 입문 - Day 5 옷가게 할인 받기class Solution { public static int solution(int price) { int answer = 0; if(price >= 100000 && price = 300000 && price = 500000){ answer = (int) (price - (price * 0.2)); System.out.println(answer); }else { answer = price; } return answer; }}아이스 아메리카노class Solution { public int[] solution(int money) { .. 2025. 4. 12. 프로그래머스 - 코딩테스트 입문 Day 4 피자 나눠먹기 (1)class Solution { public int solution(int n) { int answer = 0; if(n%7 == 0){ answer = n/7; } else{ answer = n/7 + 1; } return answer; }}피자 나눠먹기 (2)class Solution { public static int solution(int n) { int p = n; //6과 n의 최소 공배수 while(n % 6 != 0){ n += p; } return n/6; .. 2025. 4. 12. 리트 코드 - 1768. Merge Strings Alternately 1768. Merge Strings AlternatelySolvedEasyTopicsCompaniesHintYou are given two strings word1 and word2. Merge the strings by adding letters in alternating order, starting with word1. If a string is longer than the other, append the additional letters onto the end of the merged string.Return the merged string.Example 1:Input: word1 = "abc", word2 = "pqr"Output: "apbqcr"Explanation: The merged stri.. 2025. 4. 5. 프로그래머스 - 코딩테스트 입문 Day 3 1. 나머지 구하기 class Solution { public int solution(int num1, int num2) { return num1 % num2; } } 2. 중앙값 구하기 import java.util.*; class Solution { public int solution(int[] array) { Arrays.sort(array); int idx = array.length / 2; return array[idx]; } } 3. 최빈값 구하기import java.util.*;class Solution { public int solution(int[] array) { int max.. 2025. 4. 5. 프로그래머스 - 코딩테스트 입문 Day 2 1. 두 수의 나눗셈import java.util.*;class Solution { public int solution(int num1, int num2) { return (int)Math.floor((float) num1 / (float) num2 * 1000); }} 2. 숫자 비교하기class Solution { public int solution(int num1, int num2) { if(num1 == num2){ return 1 ; } return -1 ; }} 3. 분수의 덧셈class Solution { public int[] solution(int numer1, int denom1, i.. 2025. 4. 5. 이전 1 2 3 4 5 다음 728x90 반응형