본문 바로가기
반응형

프로그래머스234

(Python/LV1)공원 산책 문제 출처 : https://school.programmers.co.kr/learn/courses/30/lessons/172928 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 풀이: def solution(park, routes): answer = [] start = [] for i in range(len(park)): if 'S' in park[i]: start = [i, park[i].find('S')] break print(start) for route in routes: dir, move = route.split(' ') move = int(mo.. 2023. 4. 1.
(Python/LV1)추억 점수 문제 출처: https://school.programmers.co.kr/learn/courses/30/lessons/176963 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 풀이: def solution(name, yearning, photo): dic = {x:y for x,y in zip(name,yearning)} res = [] for i in range(len(photo)): result = 0 for z in photo[i]: if z in dic: result += dic[z] res.append(result) return res 2023. 4. 1.
(Python/🥉3)백준알고리즘 2501번: 약수 구하기 문제출처: https://www.acmicpc.net/problem/2501 2501번: 약수 구하기 첫째 줄에 N과 K가 빈칸을 사이에 두고 주어진다. N은 1 이상 10,000 이하이다. K는 1 이상 N 이하이다. www.acmicpc.net 풀이: import sys N, K = list(map(int,input().split(" "))) les = [] for i in range(1,N+1): if N% i ==0 : les.append(i) if K > len(les): print(0) else: print(les[K-1]) 2023. 3. 22.
(Python/LV2) 리코쳇 로봇 문제출처: https://school.programmers.co.kr/learn/courses/30/lessons/169199 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 풀이: from collections import deque def solution(board): visited = [[0] * len(board[0]) for i in range(len(board))] move = [(0,1),(0,-1),(1,0),(-1,0)] visited = set() Q = deque() for idx, i in enumerate(board): for idy.. 2023. 3. 21.
(Python/LV3)숫자 게임 문제 출처:https://school.programmers.co.kr/learn/courses/30/lessons/12987 풀이 : from collections import deque def solution(A, B): idx = 0 A = deque(sorted(A)) B = deque(sorted(B)) count = 0 while len(B) > 0 and len(A) > 0: left, right = A.popleft(), B.popleft() if right > left : count += 1 else: idx += 1 A.appendleft(left) return count idx 인덱스 A,B 를 메모리 땜에 Deauq 하였다 count 는 총 이긴수 어차피 A 의 숫자는 알고 있다, 그.. 2023. 3. 3.
(Python/LV1)바탕화면 정리 문제출처: https://school.programmers.co.kr/learn/courses/30/lessons/161990 풀이: def solution(wallpaper): n, m = len(wallpaper), len(wallpaper[0]) s_x, s_y, l_x, l_y = 51, 51, 0, 0 for i in range(n): for j in range(m): if wallpaper[i][j] == "#": s_x = min(s_x, i) s_y = min(s_y, j) l_x = max(l_x, i) l_y = max(l_y, j) return s_x,s_y,l_x + 1,l_y + 1 2023. 3. 2.
반응형