본문 바로가기

알고리즘

(86)
[프로그래머스] 모음사전 https://school.programmers.co.kr/learn/courses/30/lessons/84512 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr 접근방법 1. 모든 중복순열을 만든다  중복순열을 만들기 위해 product모듈을 사용한다 list(product(["A", "E", "I", "O", "U"], repeat = i)) 해당 product 코드를 1부터 5까지 하면 A, E, I, O ,U,(A,A), (A,E),( A,I)...(A,A,A), (A,A,E),( A,A,I)....(A,A,A,A)....(A,A,A,A,A)...인 중..
[leetcode] House Robber - Python 문제링크https://leetcode.com/problems/house-robber/ LeetCode - The World's Leading Online Programming Learning PlatformLevel 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 문제풀이 0과1을 초기memo로 지정해주고 이웃되지 않으면 되니까 -2 step만 확인해서 더해주면 되겠다고 생각하였습니다. class Solution: def rob(self, nums: List[int]) -> int: ..
[leetcode] unique-paths - Python 문제링크 https://leetcode.com/problems/unique-paths/submissions/1179788926/ 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 문제풀이 m x n 크기의 grid에 로봇이 오른쪽이나 아래로만 이동합니다. 이때 가장 오른쪽 아래지점 즉 (m-1, n-1)지점으로 가는 모든 경우의 수의 path를 구하는 문제입니다..
[leetcode] min cost climbing stairs - Python 문제링크 https://leetcode.com/problems/min-cost-climbing-stairs/ 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 문제풀이 이번문제는 주어진 cost를 단계를 밟고 올라가 ( 1step or 2step ) 정상으로 가는 최소의 비용을 구하는 것입니다. 이때 cost의 마지막 또는 마지막 전 index까지만 가면 됩니다..
[leetcode] Climbing Stairs - Python 문제 https://leetcode.com/problems/climbing-stairs/submissions/1179719047/ 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 문제파악 이 문제는 계단을 올라가는데 각 칸수에 맞게 올라가는 경우의 수를 세는 것입니다.(1step or 2step) ex) 1칸은 1개의 방법 2칸은 1+1 , 2 두가지 방법 3..
[Leetcode] Group Anagrams - 파이썬 문제링크 https://leetcode.com/problems/group-anagrams/description/ 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 접근방법 해당문제는 입력받은 배열에서 철자가 같은 문자열끼리 묶어 이중배열로 return 해주는 문제였습니다. 10^4이라서 O(N)의 접근법이 필요합니다. 길이가 0과 1인 입력은 따로 처리를 해주었..
[프로그래머스] 문자열 압축 - 파이썬 문제링크 https://school.programmers.co.kr/learn/courses/30/lessons/60057 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 해당 문제는 입력받은 문자열의 절반만큼의 수로 문자열을 잘라서 비교하는 문제입니다. 1. for문으로 1,2,... len(s) // 2 +1 까지 자를 수를 정한다. 2. stack을 사용하여 해당 자를 수가되면 비교를한다 3 현재 자른 결과를 answer와 비교하여 최소값을 찾는다 def solution(s): answer = 1001 # 1개가 들어올 경우 1 return if le..
[프로그래머스] 신규 아이디 추천- 파이썬 문제링크 https://school.programmers.co.kr/learn/courses/30/lessons/72410?language=python3 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 해당 문제는 문제에 제시된 순서대로 코드를 작성하면 되는 문제였습니다. step별로 해당하는 내장함수를 작성하였습니다. # 주어진 문자열의 모든 대문자를 대응되는 소문자로 치환한다 step1 = new_id.lower() lower() 해당 내장함수는 문자열에 알파벳에 해당하는 문자를 소문자로 변경합니다 ex) “12SVaa” ⇒ “12svaa” while ..