목록프로그래머스 (93)
csct3434
문제 링크 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr import java.util.*; class Solution { public int solution(int x, int y, int n) { Set visited = new HashSet(); Queue queue = new LinkedList(); queue.add(new int[]{x, 0}); while (!queue.isEmpty()) { int[] info = queue.poll(); int number = info[0], count = info[1]; int[] nextNumbers =..
문제 링크 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr import java.util.*; class Solution { public int solution(String begin, String target, String[] words) { int n = words.length; int targetIdx = -1; int[][] diff = new int[n][n]; for (int i = 0; i < n; i++) { if (words[i].equals(target)) { targetIdx = i; } for (int j = i + 1; j < n; ..
문제 링크 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr class Solution { public int solution(int n, int[][] computers) { int answer = 0; boolean[] visited = new boolean[n]; for(int i=0; i
문제 링크 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr import java.util.*; class Solution { public int solution(int[][] routes) { int answer = 0, last = -30001; Arrays.sort(routes, Comparator.comparingInt(a -> a[1])); for(int[] route : routes) { if(route[0] > last) { last = route[1]; answer++; } } return answer; } }
문제 링크 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr import java.util.*; class Solution { private int[] parent; public int solution(int n, int[][] costs) { int answer = 0, count = 0, total = (n * n - n) / 2; parent = new int[n + 1]; for (int i = 1; i a[2])); for (int[] cost : costs) { int px = find(cost[0]); int py = find(cost[1]); ..
문제 링크 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr import java.util.*; class Solution { public int[] solution(String[] operations) { PriorityQueue ascPriorityQueue = new PriorityQueue(); PriorityQueue descPriorityQueue = new PriorityQueue(Comparator.reverseOrder()); for (String op : operations) { String[] tokens = op.split(" "); S..
문제 링크 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr import java.util.*; class Solution { public int solution(int[][] jobs) { int answer = 0; int time = 0, idx = 0, completed = 0; PriorityQueue pq = new PriorityQueue(Comparator.comparingInt(a -> a[1])); Arrays.sort(jobs, Comparator.comparingInt(a -> a[0])); while(completed < jobs.le..
문제 링크 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr import java.util.*; import java.util.Map.*; import java.util.stream.Collectors; class Solution { public int[] solution(String[] genres, int[] plays) { HashMap category = new HashMap(); HashMap count = new HashMap(); for (int i = 0; i < genres.length; i++) { String genre = genres[i..
문제 링크 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr import java.util.HashMap; import java.util.LinkedList; import java.util.List; class Solution { public long solution(int[] weights) { long answer = 0; HashMap countPerWeight = new HashMap(); HashMap torqueMap = new HashMap(); for (int k : weights) { countPerWeight.put(k, countPerWe..
문제 링크 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr import java.util.Arrays; import java.util.stream.IntStream; class Solution { public int solution(int[][] data, int col, int row_begin, int row_end) { Arrays.sort(data, (a, b) -> a[col - 1] == b[col - 1] ? b[0] - a[0] : a[col - 1] - b[col - 1]); return IntStream.rangeClosed(row_beg..