코-딩

코-딩/Leetcode

[leetcode] 62. Unique Paths

문제 : https://leetcode.com/problems/unique-paths/description/ 난이도 : Medium 풀이 1) dp로 풀기 class Solution: def uniquePaths(self, m: int, n: int) -> int: if not m or not n: return 0 cur = [1] * n for i in range(1, m): for j in range(1, n): cur[j] += cur[j - 1] return cur[-1] 2) 수학적으로 풀기 class Solution: def uniquePaths(self, m: int, n: int) -> int: return factorial(m+n-2) // factorial(m-1) // factoria..

코-딩/Leetcode

[leetcode] 1331. Rank Transform of an Array

문제 : https://leetcode.com/problems/rank-transform-of-an-array/description/ Rank Transform of an Array - LeetCode Can you solve this real interview question? Rank Transform of an Array - Given an array of integers arr, replace each element with its rank. The rank represents how large the element is. The rank has the following rules: * Rank is an integer starting from leetcode.com 난이도 : Easy 풀이 cl..

코-딩/Leetcode

[leetcode] 1417. Reformat The String

문제 : https://leetcode.com/problems/reformat-the-string/description/ Reformat The String - LeetCode Can you solve this real interview question? Reformat The String - You are given an alphanumeric string s. (Alphanumeric string is a string consisting of lowercase English letters and digits). You have to find a permutation of the string where no letter is leetcode.com 난이도 : Easy 풀이 class Solution: ..

코-딩/Leetcode

[leetCode] 1592. Rearrange Spaces Between Words

문제 : https://leetcode.com/problems/rearrange-spaces-between-words/description/ Rearrange Spaces Between Words - LeetCode Can you solve this real interview question? Rearrange Spaces Between Words - You are given a string text of words that are placed among some number of spaces. Each word consists of one or more lowercase English letters and are separated by at least one spa leetcode.com 난이도 : E..

코-딩/프로그래머스

프로그래머스::키패드 누르기(python)

문제 : https://school.programmers.co.kr/learn/courses/30/lessons/67256 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 난이도 : Lv.1 풀이 def solution(numbers, hand): answer = '' # L: 왼손, R: 오른손 L = '*' R = '#' # 키패드 keypad = {0:(3,1), 1:(0,0), 2:(0,1), 3:(0,2), 4:(1,0), 5:(1,1), 6:(1,2), 7:(2,0), 8:(2,1), 9:(2,2), '*':(3,0), '#':(3,2)} for..

코-딩/Leetcode

[leetcode] 17. Letter Combinations of a Phone Number

문제 : https://leetcode.com/problems/letter-combinations-of-a-phone-number/ 난이도 : Medium 풀이 class Solution: def letterCombinations(self, digits: str) -> List[str]: dict = {'2':"abc", '3':"def", '4':"ghi", '5':"jkl", '6':"mno", '7': "pqrs", '8':"tuv", '9':"wxyz"} comb = [''] if digits else [] for d in digits: comb = [p + q for p in comb for q in dict[d]] return comb

힞뚜루마뚜루
'코-딩' 카테고리의 글 목록