728x90 반응형 알고리즘 문제풀이146 프로그래머스 - 기사단원의 무기 class Solution { public int solution(int number, int limit, int power) { int answer = 0; for(int i=1; i 2023. 5. 8. 프로그래머스 - 연속 부분 수열 합의 개수 import java.util.*; class Solution { public int solution(int[] elements) { Set set = new HashSet(); int count = 1; int len = elements.length; while(count != len+1){ for(int i=0; i 2023. 5. 6. 프로그래머스 - 구명보트 import java.util.*; class Solution { public int solution(int[] people, int limit) { int answer = 0; int k = 0; Arrays.sort(people); for(int i=people.length-1; i>=k; i--){ if(people[i] + people[k] 2023. 4. 21. 프로그래머스 - 카펫 class Solution { public int[] solution(int brown, int yellow) { int x = 0; // yellow의 x길이 int y = 0; // yellow의 y길이 // yellow를 구해서 while(brown != (x+2) * 2 + (y*2)){ y++; if((yellow >= y*y) && (yellow % y == 0)){ // yellow가 y축 제곱 이상이고 y의 배수인 경우 x = yellow/y; } } return new int[]{x+2, y+2}; } } 2023. 4. 21. 이전 1 2 3 4 ··· 37 다음 728x90 반응형