Coding Test/Java 19

[프로그래머스 / Java] Lv.1 자릿수 더하기

Question https://school.programmers.co.kr/learn/courses/30/lessons/12931 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.krCodeimport java.util.*;public class Solution { public int solution(int n) { int answer = 0; while(n > 0) { answer += n % 10; n = n / 10; } return answer; }}n % 10 : n의 마지막 자릿수를 구..

Coding Test/Java 11:30:36

[프로그래머스 / Java] Lv.1 약수의 합

Question https://school.programmers.co.kr/learn/courses/30/lessons/12928 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.krCode💡내 풀이class Solution { public int solution(int n) { int answer = 0; for(int i = 1; i 💡참고하면 좋은 풀이class SumDivisor { public int sumDivisor(int num) { int answer = 0; for(int i = 1 ; i

Coding Test/Java 2025.04.26

[프로그래머스 / Java] Lv.0 문자 반복 출력하기

Question https://school.programmers.co.kr/learn/courses/30/lessons/120825 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.krCodeclass Solution { public String solution(String my_string, int n) { String answer = ""; String[] str = my_string.split(""); for(int i = 0; i split(String regex) regex : 문자열을 분할할 기준이 되는 정규 표현식입니다.rep..

Coding Test/Java 2025.04.26

[프로그래머스 / Java] Lv.0 아이스 아메리카노

Question https://school.programmers.co.kr/learn/courses/30/lessons/120819 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.krCode💡내 풀이class Solution { public int[] solution(int money) { int[] answer = new int[2]; answer[0] = money / 5500; answer[1] = money % 5500; return answer; }} 💡참고하면 좋은 풀이class Solution { ..

Coding Test/Java 2025.04.26

[프로그래머스 / Java] Lv.0 특정 문자 제거하기

Question https://school.programmers.co.kr/learn/courses/30/lessons/120826 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.krCodeclass Solution { public String solution(String my_string, String letter) { String answer = ""; answer = my_string.replace(letter,""); return answer; }} 💡문자열 치환 함수replace(CharSequence old, CharS..

Coding Test/Java 2025.04.26

[프로그래머스 / Java] Lv.0 짝수 홀수 개수

Question https://school.programmers.co.kr/learn/courses/30/lessons/120824 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.krCode💡 방법 1class Solution { public int[] solution(int[] num_list) { int[] result; int even = 0; int odd = 0; for(int i = 0; i * 배열 선언 및 초기화 1. 배열 선언 후 크기 지정int[] arr = new int[5]; 2. 선언과 초기화를 동..

Coding Test/Java 2025.04.26

[프로그래머스 / Java] Lv.0 제곱수 판별하기

Question https://school.programmers.co.kr/learn/courses/30/lessons/120833?language=java 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.krCode방법 1.class Solution { public int[] solution(int[] numbers, int num1, int num2) { int [] answer = new int[num2 - num1 + 1]; int index = 0; for (int i = num1; i * 배열 선언 및 초기화 1. 배열 선언 ..

Coding Test/Java 2025.04.19

[프로그래머스 / Java] Lv.0 최댓값 만들기(1) (업데이트 중...)

Question https://school.programmers.co.kr/learn/courses/30/lessons/120847 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.krCode방법 1) 오름차순 정렬 → 마지막 -1 인덱스 접근import java.util.*;class Solution { public int solution(int[] numbers) { // 배열을 오름차순으로 정렬 Arrays.sort(numbers); // 정렬된 배열에서 가장 큰 두 수를 곱해서 반환 return numbers[numbers.length-1..

Coding Test/Java 2025.03.13

[프로그래머스 / Java] Lv.0 제곱수 판별하기

Question https://school.programmers.co.kr/learn/courses/30/lessons/120909 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.krCodeclass Solution { public int solution(int n) { if(Math.sqrt(n) % 1 == 0) { return 1; } else { return 2; } }}Math.sqrt : 숫자 n의 제곱근을 계산ex. n = 16이면, Math.sqrt(16)은 4.0ex. n = 18이면, Mat..

Coding Test/Java 2025.01.25
반응형