분류 전체보기

코딩테스트/코딩테스트 문제풀이

[Python] 프로그래머스 <무인도 여행>

https://school.programmers.co.kr/learn/courses/30/lessons/154540 프로그래머스SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr from collections import dequedef bfs(a, b, maps, visited): # 각 구역에 대한 값 저장 dap = 0 dx = [1, -1, 0, 0] dy = [0, 0, 1, -1] N, M = len(maps), len(maps[0]) dq = deque() dq.append((a, b)) dap += int(maps[a][b]) while dq: ..

코딩테스트/코딩테스트 문제풀이

[Python] 프로그래머스 <야근 지수>

https://school.programmers.co.kr/learn/courses/30/lessons/12927 프로그래머스SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr - 효율성 체크 실패 (시간 초과)def solution(n, works): answer = 0 works.sort() for _ in range(n): works.append(works.pop()-1) works.sort() for i in works: if i > 0: answer += i*i return answer - 정답 코드import heapq..

코딩테스트/코딩테스트 문제풀이

[Python] 프로그래머스 <시소 짝꿍>

https://school.programmers.co.kr/learn/courses/30/lessons/152996 from collections import Counterfrom itertools import combinationsdef solution(weights): answer = 0 # 시소 거리 경우의 수 dis_li = [(1, 1), (2, 3), (3, 2), (2, 4), (4, 2), (3, 4), (4, 3)] # 무게 카운트 counter = dict(Counter(weights)) # 중복 제거한뒤 2명 경우의 수 unique_weights = list(combinations(sorted(counter.keys()), 2)) ..

코딩테스트/코딩테스트 문제풀이

[Python] 백준 <1261-알고스팟>

https://www.acmicpc.net/problem/1261 import sysfrom collections import dequeinput = sys.stdin.readlinedef bfs(a, b): dx = [1, -1, 0, 0] dy = [0, 0, 1, -1] dq = deque() # 첫 좌표 dq.append([a, b]) # 방문 처리 wall[a][b] = 0 while dq: x, y = dq.popleft() for i in range(4): nx, ny = x+dx[i], y+dy[i] if nx = N or ny >= M: continue ..

Yang Ji Woo
'분류 전체보기' 카테고리의 글 목록 (17 Page)