프로그래머스 스쿨 - 요격 시스템(Python)(복습)
# targets = [[4,5],[4,8],[10,14],[11,13],[5,12],[3,7],[1,4]] # print(targets.sort(key = lambda x: [x[1], x[0]])) // key = function을 통해 원하는 값을 만들어 오름차순 정렬 # print(targets) def solution(targets): answer = 0 targets.sort(key = lambda x: [x[1], x[0]]) e = 0 for target in targets: if target[0] >= e: answer += 1 e = target[1] return answer
2023. 10. 8.
프로그래머스 스쿨 - 신고 결과 받기(Python)(복습)
# id_list = ["muzi", "frodo", "apeach", "neo"] # reported = {x: 0 for x in id_list} # print(reported["muzi"]) def solution(id_list, report, k): answer = [0] * len(id_list) reported = {x: 0 for x in id_list} # dictionary, key - x, value - 0 for r in set(report): # set method - 순서가 없고, 집합안에서는 unique한 값 출력 a,b = r.split() reported[b] += 1 for r in set(report): a,b = r.split() if reported[b] >= k: a..
2023. 10. 6.