전체 글 959

[programmers] 전국 대회 선발 고사

문제https://school.programmers.co.kr/learn/courses/30/lessons/181851 프로그래머스SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 문제 풀이 (Java)import java.util.*;class Solution { public int solution(int[] rank, boolean[] attendance) { int answer = 0; ArrayList list = new ArrayList(); for (int i = 0; i () { @Override public int compare(int[] o1, int[] o2) { return o1[1] -..

[programmers] 소인수분해

문제https://school.programmers.co.kr/learn/courses/30/lessons/120852 프로그래머스SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 문제 풀이 (Java)import java.util.*;class Solution { public int[] solution(int n) { int[] answer = {}; HashSet set = new HashSet(); while (n > 1) { for (int i = 2; i 2부터 n이하까지 순회하며 n이 나눠지는지 확인한다. 나눠진다면 set에 나눈 값을 저장하고 n을 업데이트한다. 이 과정을 n이 1보다 클 때 계속해서..

[programmers] 한 번만 등장한 문자

문제https://school.programmers.co.kr/learn/courses/30/lessons/120896 프로그래머스SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 문제 풀이 (Java)import java.util.*;class Solution { public String solution(String s) { String answer = ""; HashMap map = new HashMap(); for (int i = 0; i list = new ArrayList(map.keySet()); Collections.sort(list, new Comparator() { @Override publi..

[programmers] 숨어있는 숫자의 덧셈 (2)

문제https://school.programmers.co.kr/learn/courses/30/lessons/120864 프로그래머스SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 문제 풀이 (Java)class Solution { public int solution(String my_string) { int answer = 0; String str = ""; for (int i = 0; i 0) { answer += Integer.parseInt(str); str = ""; } } } if (str.length() > 0) { answer += Integer.parseInt(str);..

[programmers] 모스부호 (1)

문제https://school.programmers.co.kr/learn/courses/30/lessons/120838 프로그래머스SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 문제 풀이 (Java)import java.util.*;class Solution { public String solution(String letter) { String answer = ""; HashMap map = new HashMap(); map.put(".-", 'a'); map.put("-...", 'b'); map.put("-.-.", 'c'); map.put("-..", 'd'); map.put(".", 'e'); map..

[programmers] 진료순서 정하기

문제https://school.programmers.co.kr/learn/courses/30/lessons/120835 프로그래머스SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 문제 풀이 (Java)import java.util.*;class Solution { public int[] solution(int[] emergency) { int[] answer = new int[emergency.length]; ArrayList list = new ArrayList(); for (int i = 0; i () { @Override public int compare(int[] o1, int[] o2) { re..

[programmers] 캐릭터의 좌표

문제https://school.programmers.co.kr/learn/courses/30/lessons/120861 프로그래머스SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 문제 풀이 (Java)class Solution { public int[] solution(String[] keyinput, int[] board) { int[] answer = { 0, 0 }; for (int i = 0; i = -(board[0] / 2)) { answer[0] -= 1; } } else if (keyinput[i].equals("right")) { if (answer[0] + 1 = -(board[..

[programmers] 특이한 정렬

문제https://school.programmers.co.kr/learn/courses/30/lessons/120880 프로그래머스SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 문제 풀이 (Java)import java.util.*;class Solution { public int[] solution(int[] numlist, int n) { int[] answer = new int[numlist.length]; ArrayList list = new ArrayList(); for (int i = 0; i () { @Override public int compare(Integer o1, Integer o2) {..

[programmers] 연속된 수의 합

문제https://school.programmers.co.kr/learn/courses/30/lessons/120923 프로그래머스SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 문제 풀이 (Java)class Solution { public int[] solution(int num, int total) { int[] answer = new int[num]; int start = -100, end = -100 + num; int sum = 0; for (int i = start; i 시작을 -100으로 하여 num개의 연속된 수를 더한다. 맨 앞의 값을 빼고, 뒤에 값을 추가해 주는 방식으로 합이 total과 같..

[programmers] 다음에 올 숫자

문제https://school.programmers.co.kr/learn/courses/30/lessons/120924 프로그래머스SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 문제 풀이 (Java)class Solution { public int solution(int[] common) { int answer = 0; int d = common[1] - common[0]; double r = (double) common[1] / common[0]; if (common[1] + d == common[2]) { answer = common[common.length - 1] + d; } else { answ..