반응형 Problem Solving232 [리트코드 leetcode] 687. Longest Univalue Path leetcode.com/problems/longest-univalue-path/ Longest Univalue Path - 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 # Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right c.. 2021. 4. 12. [리트코드 leetcode] 104. Maximum Depth of Binary Tree leetcode.com/problems/maximum-depth-of-binary-tree/ Maximum Depth of Binary Tree - 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 # Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.r.. 2021. 4. 12. [리트코드 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. 이전 1 ··· 33 34 35 36 37 38 39 다음 반응형