프로그래머스/Lv. 1 - 자바77 콜라츠 추측 풀이 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. x만큼 간격이 있는 n개의 숫자 풀이 class Solution { public long[] solution(int x, int n) { long[] answer = new long[n]; for(int i=1; i 2024. 2. 6. 이전 1 2 3 4 5 6 7 8 ··· 13 다음