본문 바로가기
반응형

Problem Solving/리트코드44

[리트코드 leetcode] 787. Cheapest Flights Within K Stops leetcode.com/problems/cheapest-flights-within-k-stops/ Cheapest Flights Within K Stops - LeetCode 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 class Solution: def findCheapestPrice(self, n: int, flights: List[List[int]], src: int, dst: int, K: int) -> int: graph = collections.defaultdict.. 2021. 4. 12.
[리트코드 leetcode] 78. Subsets leetcode.com/problems/subsets/ Subsets - LeetCode 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 class Solution: def subsets(self, nums: List[int]) -> List[List[int]]: result = [] def dfs(path, lst): result.append(path) if not lst: return for num in lst: dfs(path+[num], lst[lst.index(num)+.. 2021. 4. 12.
[리트코드 leetcode] 77. Combinations leetcode.com/problems/combinations/ Combinations - LeetCode 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 class Solution: def combine(self, n: int, k: int) -> List[List[int]]: nums = [i for i in range(1,n+1)] result = [] def dfs(lst, unused): if len(lst)==k: result.append(lst) return for .. 2021. 4. 12.
[리트코드 leetcode] 46. Permutations leetcode.com/problems/permutations/ Permutations - LeetCode 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 class Solution: def permute(self, nums: List[int]) -> List[List[int]]: results=[] def dfs(result=[],next=[]): if len(result)==len(nums): results.append(result[:]) return for i in rang.. 2021. 4. 12.
[리트코드 leetcode] 17. Letter Combinations of a Phone Number leetcode.com/problems/letter-combinations-of-a-phone-number/ Letter Combinations of a Phone Number - LeetCode 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 class Solution: def letterCombinations(self, digits: str) -> List[str]: dict ={ '2':'abc', '3':'def', '4':'ghi', '5':'jkl', '6':'mno'.. 2021. 4. 12.
[리트코드 leetcode] 200. Number of Islands leetcode.com/problems/number-of-islands/ Number of Islands - LeetCode 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 class Solution: def numIslands(self, grid: List[List[str]]) -> int: row = len(grid[0]) col = len(grid) def dfs(y,x): if (0 2021. 4. 12.
반응형