전체 글88 최대공약수와 최소공배수 풀이 class Solution { public int[] solution(int n, int m) { int[] answer = {0,0}; int max = n; int min = m; if(n =1; i--){ if(min%i ==0 && max%i ==0){ answer[0] = i; answer[1] = min*max / i; break; } } } return answer; } } 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 2024. 2. 6. 콜라츠 추측 풀이 class Solution { public long solution(long num) { long answer = 0; while (num != 1) { if (num % 2 == 0) { num = num / 2; } else { num = num * 3 + 1; } answer++; // 무한 루프 방지 if (answer > 500) { answer = -1; break; } } return answer; } } 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 2024. 2. 6. 평균 구하기 풀이 class Solution { public double solution(int[] arr) { double answer = 0; double sum = 0; for(int i=0; i 2024. 2. 6. 하샤드 수 풀이 class Solution { public boolean solution(int x) { boolean answer = true; int sum = 0; for(int i=0; i 2024. 2. 6. 핸드폰 번호 가리기 풀이 class Solution { public String solution(String phone_number) { String answer = ""; for(int i=0; i 2024. 2. 6. 행렬의 덧셈 풀이 class Solution { public int[][] solution(int[][] arr1, int[][] arr2) { int[][] answer = new int[arr1.length][arr1[0].length]; for(int i=0; i 2024. 2. 6. 이전 1 2 3 4 5 6 7 8 ··· 15 다음