목록프로그래머스 (93)
csct3434
문제 링크 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr import java.util.HashSet; import java.util.Set; class Solution { private Set answer = new HashSet(); public int solution(String numbers) { boolean[] visited = new boolean[numbers.length()]; int[] selected = new int[numbers.length()]; for (int count = 1; count
문제 링크 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr import java.util.Arrays; class Solution { public int solution(int[] citations) { int answer = 0; int total = citations.length; Arrays.sort(citations); int index = 0; for (int h = 0; h
문제 링크 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr import java.util.Arrays; class Solution { public String solution(int[] numbers) { String answer = Arrays.stream(numbers) .mapToObj(String::valueOf) .sorted((a, b) -> (b + a).compareTo(a + b)) .reduce("", (a, b) -> a + b); return answer.equals("0".repeat(answer.length())) ? "0" : a..
문제 링크 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr import java.util.PriorityQueue; class Solution { public int solution(int[] scoville, int K) { int answer = 0; PriorityQueue pq = new PriorityQueue(); for (int scv : scoville) { pq.add(1L * scv); } while (pq.size() > 1) { if (pq.peek() >= K) { return answer; } Long scv1 = pq.poll()..
문제 링크 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr class Solution { public int solution(int[] priorities, int location) { int answer = 0; PriorityQueue pq = new PriorityQueue(Comparator.comparing(m -> -m)); Queue queue = new LinkedList(); for (int i = 0; i < priorities.length; i++) { queue.add(i); pq.add(priorities[i]); } while (q..
문제 링크 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr class Solution { public int[] solution(int[] progresses, int[] speeds) { ArrayList answer = new ArrayList(); int[] finishTime = new int[progresses.length]; for (int i = 0; i < progresses.length; i++) { finishTime[i] = (int) Math.ceil((100D - progresses[i]) / speeds[i]); } for (int..
문제 링크 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr import java.util.Comparator; import java.util.PriorityQueue; class Solution { public int[] solution(int[] prices) { PriorityQueue pq = new PriorityQueue(Comparator.comparingInt(m -> -m[0])); int[] answer = new int[prices.length]; for (int i = 0; i < prices.length; i++) { while (!p..
문제 링크 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr import java.util.LinkedList; class Solution { public int solution(int bridge_length, int weight, int[] truck_weights) { int currentTime = 0; int totalWeight = 0; LinkedList onBridge = new LinkedList(); for (int truckWeight : truck_weights) { currentTime++; while ((!onBridge.isEmpt..
문제 링크 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr import java.util.HashMap; class Solution { public int solution(String[][] clothes) { HashMap clothesInfo = new HashMap(); for (String[] clothe : clothes) { clothesInfo.put(clothe[1], 1 + clothesInfo.getOrDefault(clothe[1], 1)); } return clothesInfo.values().stream().reduce((a, b) ..
문제 링크 class Solution { public boolean solution(String[] phone_book) { HashMap map = new HashMap(); for (String number : phone_book) { map.put(number, true); } for (String number : phone_book) { for (int i = 1; i < number.length(); i++) { if (map.containsKey(number.substring(0, i))) { return false; } } } return true; } }