본문 바로가기

전체 글

(315)
프로그래머스 - 42888번: 오픈채팅방 [Java] 문제: https://school.programmers.co.kr/learn/courses/30/lessons/42888 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 1. 코드 import java.util.*; class Solution { public List solution(String[] record) { List list = new ArrayList(); Map map = new HashMap(); for(String r : record) { String[] s = r.split(" "); list.add(s[1] + " "+ s[0]); if..
프로그래머스 - 43163번: 단어 변환 [Java] (실패) 문제: https://school.programmers.co.kr/learn/courses/30/lessons/43163 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 1. 코드 import java.util.*; class Solution { static int answer = Integer.MAX_VALUE; static boolean[] check; public int solution(String begin, String target, String[] words) { check = new boolean[words.length]; dfs(begin, ..
프로그래머스 - 42626번: 더 맵게 [Java] 문제: https://school.programmers.co.kr/learn/courses/30/lessons/42626 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 1. 코드 import java.util.*; class Solution { public int solution(int[] scoville, int K) { int answer = 0; PriorityQueue queue = new PriorityQueue(); for(int s : scoville) queue.offer(s); while(queue.peek() < K && queue.si..
프로그래머스 - 92341번: 주차 요금 계산 [Java] 문제: https://school.programmers.co.kr/learn/courses/30/lessons/92341 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 1. 코드 import java.util.*; import java.time.*; import java.time.temporal.ChronoField; class Solution { public List solution(int[] fees, String[] records) { List answer = new ArrayList(); Map price = new TreeMap(); Map ti..
프로그래머스 - 17687번: [3차] n진수 게임 [Java] 문제: https://school.programmers.co.kr/learn/courses/30/lessons/17687 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 1. 코드 import java.util.*; class Solution { public String solution(int n, int t, int m, int p) { StringBuilder answer = new StringBuilder(); int cnt = 0; for(int i = 0; answer.toString().length() < t; i++) { String s = c..
프로그래머스 - 12927번: 야근 지수 [Java] 문제: https://school.programmers.co.kr/learn/courses/30/lessons/12927 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 1. 코드 import java.util.*; class Solution { public long solution(int n, int[] works) { long answer = 0; PriorityQueue queue = new PriorityQueue(Collections.reverseOrder()); for(int w : works) queue.add(w); for(int i = 0;..
프로그래머스 - 12938번: 최고의 집합 [Java] 실패 문제: https://school.programmers.co.kr/learn/courses/30/lessons/12938 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 1. 코드 class Solution { public int[] solution(int n, int s) { if(n > s) return new int[] {-1}; int[] answer = new int[n]; int index = 0; while(n > 0){ int value = s/n; answer[index++] = value; s -= value; n--; } return a..
프로그래머스 - 17684번: [3차] 압축 [Java] 문제: https://school.programmers.co.kr/learn/courses/30/lessons/17684 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 1. 코드 import java.util.*; class Solution { public List solution(String msg) { List list = new ArrayList(); Map map = new HashMap(); int index = 1; for(char c = 'A'; c