분류 전체보기70 [프로그래머스] 같은 숫자는 싫어 프로그래머스 1단계 같은 숫자는 싫어 https://programmers.co.kr/learn/challenges 문제 설명 풀이 import java.util.*; public class Solution { public int[] solution(int []arr) { ArrayList list = new ArrayList(); int checkNum = 10; for(int i : arr) { if(checkNum != i) { list.add(i); checkNum = i; } } int[] answer = new int[list.size()]; for(int i=0; i 2022. 4. 25. [프로그래머스] 음양 더하기 프로그래머스 1단계 음양 더하기 https://programmers.co.kr/learn/challenges 문제 설명 풀이 class Solution { public int solution(int[] absolutes, boolean[] signs) { int answer = 0; for (int i = 0; i < absolutes.length; i++) { int number = signs[i] ? 1 : -1; answer += absolutes[i] * number; } return answer; } } 2022. 4. 25. [프로그래머스] 제일 작은 수 제거하기 프로그래머스 1단계 제일 작은 수 제거하기 https://programmers.co.kr/learn/challenges 문제 설명 풀이 import java.util.*; class Solution { public int[] solution(int[] arr) { ArrayList result = new ArrayList(); int copyArr[] = Arrays.copyOf(arr, arr.length); if(arr.length == 1) { result.add(-1); } else { Arrays.sort(copyArr); int key = copyArr[0]; for(int i=0; i 2022. 4. 25. [프로그래머스] 부족한 금액 계산하기 프로그래머스 1단계 부족한 금액 계산하기 https://programmers.co.kr/learn/challenges 문제 설명 풀이 class Solution { public long solution(int price, int money, int count) { long answer = money; for (; count > 0; count--) { answer -= price * count; } return answer < 0 ? (answer * -1) : 0; } } 2022. 4. 25. 이전 1 ··· 5 6 7 8 9 10 11 ··· 18 다음