greedy
-
[Programmers] 마법의 엘리베이터 / ⭕Algorithm/Programmers 2024. 7. 23. 21:44
프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr 1. 제출 코드 (52분 32초 / Greedy)import java.util.*;class Solution { public int solution(int storey) { int answer = 0; while(storey != 0) { int t = storey % 10; storey /= 10; if(t > 5) { answer += 10 - t; ..
-
[Programmers] 호텔 대실 / ⭕Algorithm/Programmers 2024. 7. 15. 17:45
프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr 1. 제출 코드 (57분 32초 / Greedy)import java.util.*;class Solution { public int solution(String[][] book_time) { int answer = 0; PriorityQueue pq = new PriorityQueue((o1, o2) -> { String[] s1 = o1.split(":"); String[] s2 = o2.split(":"); if(Inte..