본문 바로가기

프로그래머스146

월간 코드 챌린지 시즌1 > 삼각 달팽이 - Python, 구현 https://school.programmers.co.kr/learn/courses/30/lessons/68645 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr  코드 & 풀이 def solution(n): snail = [[0] * n for _ in range(n)] direction = [(1, 0), (0, 1), (-1, -1)] x, y, num = -1, 0, 0 for i in range(n): dx, dy = direction[i%3] for j in range(n - i): x += dx y .. 2024. 12. 17.
연속된 부분 수열의 합 - Python, 부분합, 슬라이딩 윈도우 https://school.programmers.co.kr/learn/courses/30/lessons/178870 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 코드 & 풀이 def solution(sequence, k): answer = [] L, R, total, minCnt = 0, 0, 0, len(sequence) while R k and L R - L: minCnt = R - L answer = [L, R] R += 1 return answer 매번 합을 구하면 비효율적이겠죠 그렇기 때.. 2024. 12. 16.
2023 KAKAO BLIND RECRUITMENT > 택배 배달과 수거하기 - Pyton, 구현 https://school.programmers.co.kr/learn/courses/30/lessons/150369 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 코드 & 풀이 def solution(cap, n, deliveries, pickups): answer = 0 delivery_idx, pickup_idx = n - 1, n - 1 def check_endpoint(idx, task): while idx >= 0 and task[idx] == 0: idx -= 1 return idx def move(idx, ta.. 2024. 12. 9.
2024 KAKAO WINTER INTERNSHIP > 가장 많이 받은 선물 - Python, 구현 https://school.programmers.co.kr/learn/courses/30/lessons/258712?language=python3 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 코드 def solution(friends, gifts): size = len(friends) friends_idx = {name:i for i, name in enumerate(friends)} history = [[0] * size for _ in range(size)] gift_sub = [0] * size result = [0] * size for gift in gi.. 2024. 12. 8.
PCCP 기출문제 > 붕대 감기 - Pyton, 구현 https://school.programmers.co.kr/learn/courses/30/lessons/250137 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 코드 & 풀이 def solution(bandage, health, attacks): max_health = health bonus_standard, heal_per_sec, bonus_heal = bandage for i in range(len(attacks)): if i == 0: health -= attacks[i][1] else: gap = attacks[.. 2024. 12. 8.
2021 KAKAO BLIND RECRUITMENT > 신규 아이디 추천 - Python, 정규표현식 https://school.programmers.co.kr/learn/courses/30/lessons/72410 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 코드 import redef solution(new_id): new_id = re.sub(r'[^a-z0-9_.-]', '', new_id.lower()) new_id = re.sub(r'\.{2,}', '.', new_id).strip('.') new_id = "aaa" if not new_id else new_id[:15].rstrip('.') return new_id.ljust(3, new_id[-1])  정규표현식을.. 2024. 12. 7.