본문 바로가기
728x90

알고리즘53

[프로그래머스] 예산 프로그래머스 1단계 예산 https://programmers.co.kr/learn/challenges 문제 설명 풀이 import java.util.Arrays; class Solution { public int solution(int[] d, int budget) { int answer = 0; Arrays.sort(d); for (int i = 0; i= 0) { budget-=d[i]; answer++; } else { break; } } return answer; } } 2022. 4. 24.
[프로그래머스] 모의고사 프로그래머스 1단계 모의고사 https://programmers.co.kr/learn/challenges 문제 설명 풀이 import java.util.*; import java.lang.*; class Solution { public int[] solution(int[] answers) { int student1[] = {1, 2, 3, 4, 5}; int student2[] = {2, 1, 2, 3, 2, 4, 2, 5}; int student3[] = {3, 3, 1, 1, 2, 2, 4, 4, 5, 5}; ArrayList topStudent = new ArrayList(); int score[] = new int[3]; for(int i=0; i 2022. 4. 24.
[프로그래머스] 직사각형 별찍기 프로그래머스 1단계 직사각형 별찍기 https://programmers.co.kr/learn/challenges 문제 설명 풀이 import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); for(int i = 0; i 2022. 4. 24.
[프로그래머스] 자연수 뒤집어 배열로 만들기 프로그래머스 1단계 자연수 뒤집어 배열로 만들기 https://programmers.co.kr/learn/challenges 문제 설명 풀이 class Solution { public int[] solution(long n) { String number = String.valueOf(n); String numbers[] = number.split(""); int answer[] = new int[numbers.length]; for(int i=0; i 2022. 4. 24.
728x90