프로그래머스8 pccp신입사원 교육 import java.util.*; class Solution { public int solution(int[] ability, int number) { // ability 사원들의 능력치 배열 number 교육횟수 int answer = 0; //초기화 PriorityQueue pq = new PriorityQueue(); //우선순위 q for(int a : ability) { //능력치들을 전부 우선순위 배열에 넣음 pq.add(a); answer += a; } for(int i = 0; i < number; i++) { //교육횟수만큼 반복 int sum = pq.remove() + pq.remove(); //능력치가 작은 = 가장작은수 2개를 꺼내서 더하고 pq.add(sum); //두번 다시 .. 2023. 1. 18. [PCCP 모의고사 #2] 실습용 로봇 https://school.programmers.co.kr/learn/courses/15009/lessons/121687 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr class Solution { int[] dx = {0, 1, 0, -1}; int[] dy = {1, 0, -1, 0}; Point point; public void move(char command) { //명령어가 입력된 경우 switch(command) { case 'R': point.dir = (point.dir + 1) % 4; break; //오른쪽 = 시계방향 case 'L':.. 2023. 1. 15. 프로그래머스 외톨이 알파벳 https://campus.programmers.co.kr/courses/15436/lessons/132843 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr import java.util.*; class Solution { public String solution(String input_string) { String answer = ""; //외톨이 판별 맵 Map map = new HashMap(); //중복 판별 Set set = new TreeSet(); char[] carr= input_string.toCharArray(); char current.. 2022. 12. 21. [프로그래머스] 전력망 둘로 나누기_Java https://campus.programmers.co.kr/courses/15436/lessons/132841?language=java import java.util.LinkedList; import java.util.Queue; class Solution { static int[][] arr; public int solution(int n, int[][] wires) { int answer = n; arr= new int[n+1][n+1]; //1. 서로 연결되어 있는 송전탑을 찾기 for(int i=0; i 2022. 12. 20. 이전 1 2 다음