Coding Test/Python

https://leetcode.com/problems/coin-change/description/?envType=study-plan-v2&envId=top-interview-150 LeetCode - The World's Leading Online Programming Learning Platform Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com BFS 풀이 from collections import deque class Solution: def coinChange(self, ..
https://school.programmers.co.kr/learn/courses/30/lessons/42842 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 전체 코드 def solution(brown, yellow): answer = [] brown = brown // 2 r = brown c = 1 while True: if (r - 2) * (c - 1) == yellow: return [r, c+1] r -= 1 c += 1 return answer
https://school.programmers.co.kr/learn/courses/30/lessons/42839 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 아이디어 가능한 모든 조합을 구하고, 소수인지 판별하도록 구현하였다! 전체 코드 def solution(numbers): def helper(prefix, lefts): yield prefix if not lefts: return for idx, l in enumerate(lefts): yield from helper(prefix + [l], lefts[:idx]+lefts[idx+1:]) num..
https://school.programmers.co.kr/learn/courses/30/lessons/43164?language=python3 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 아이디어 처음에 bfs로 풀었다가 테케 1, 2 번을 통과하지 못했다. 문제에 아래와 같은 제시 부분이 있어서 알파벳 순서가 빠른 것 부터 탐색해서 일어난 일이었다. 만일 가능한 경로가 2개 이상일 경우 알파벳 순서가 앞서는 경로를 return 합니다. 그래서 가능한 모든 경로를 탐색하고, 정렬한 뒤 return하도록 코드를 수정하였다. 전체 코드 import cop..
lim.dev
'Coding Test/Python' 카테고리의 글 목록 (8 Page)