문제 https://school.programmers.co.kr/learn/courses/30/lessons/42840 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 코드 def solution(answers): pattern1 = [1, 2, 3, 4, 5] pattern2 = [2, 1, 2, 3, 2, 4, 2, 5] pattern3 = [3, 3, 1, 1, 2, 2, 4, 4, 5, 5] scores = [0, 0, 0] for i, answer in enumerate(answers): if answer == pattern1[i % len(pat..
자료구조&알고리즘
문제 https://school.programmers.co.kr/learn/courses/30/lessons/86491 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 코드 def solution(sizes): max_width = 0 max_height = 0 for card in sizes: width, height = sorted(card) max_width = max(max_width, width) max_height = max(max_height, height) return max_width * max_height sorted를 통해서 width와..
문제 https://school.programmers.co.kr/learn/courses/30/lessons/42747 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 코드 def solution(citations): citations.sort(reverse=True) h_index= 0 for i, citationin in enumerate(citations): h_index = max(h_index, min(i+1, citationin)) return h_index 다른 사람 코드 def solution(citations): citations.sort(..
문제 https://school.programmers.co.kr/learn/courses/30/lessons/42746 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 코드 def solution(numbers): numbers = sorted(map(str, numbers), key=lambda x: x*3, reverse=True) return str(int(''.join(numbers))) # 숫자를 문자열로 변환하고 정렬 기준을 설정하여 정렬 # 0인 경우 체크해서 제외 다른 사람 코드 import functools def comparator(a,b..
문제 https://school.programmers.co.kr/learn/courses/30/lessons/42628 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 코드 import heapq def solution(operations): max_heap = [] min_heap = [] for op in operations: command, value = op.split() value = int(value) if command == "I": heapq.heappush(min_heap, value) heapq.heappush(max_heap, -valu..
문제 https://school.programmers.co.kr/learn/courses/30/lessons/42628 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 코드 def solution(array, commands): answer = [] for command in commands: new_array = array[command[0]-1:command[1]] new_array.sort() answer.append(new_array[command[2]-1]) return answer 다른 사람 코드 def solution(array, command..
문제 https://school.programmers.co.kr/learn/courses/30/lessons/42627 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 코드 import heapq def solution(jobs): jobs_len = len(jobs) jobs.sort(key=lambda x:x[0]) heap = [] total_time, current_time = 0, 0 while jobs or heap: while jobs[0][0] 0: dur, arr = heapq.heappop(q) current_time = max(curre..
문제 https://school.programmers.co.kr/learn/courses/30/lessons/42626 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 코드 import heapq def solution(scoville, K): heapq.heapify(scoville) #힙 자료형으로 만들어줌 mix_count = 0 while scoville[0] < K: if len(scoville) < 2: return -1 new_scovile = heapq.heappop(scoville) + (heapq.heappop(scoville) * 2) ..