본문 바로가기
반응형

전체 글571

[리트코드 leetcode] 1038. Binary Search Tree to Greater Sum Tree leetcode.com/problems/binary-search-tree-to-greater-sum-tree/ Binary Search Tree to Greater Sum 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... 2021. 4. 12.
[리트코드 leetcode] 198. House Robber leetcode.com/problems/house-robber/ House Robber - 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 rob(self, nums: List[int]) -> int: if len(nums) int: if len(nums) 2021. 4. 12.
[리트코드 leetcode] 169. Majority Element leetcode.com/problems/majority-element/ Majority Element - 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 majorityElement(self, nums: List[int]) -> int: return collections.Counter(nums).most_common(1)[0][0] 2021. 4. 12.
[리트코드 leetcode] 455. Assign Cookies leetcode.com/problems/assign-cookies/ Assign Cookies - 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 findContentChildren(self, g: List[int], s: List[int]) -> int: g.sort() s.sort() result = 0 i=0 while s and i 2021. 4. 12.
[리트코드 leetcode] 134. Gas Station leetcode.com/problems/gas-station/ Gas Station - 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 canCompleteCircuit(self, gas: List[int], cost: List[int]) -> int: result = -1 for start in range(len(gas)): fuel =0 for i in range(sta.. 2021. 4. 12.
[리트코드 leetcode] 406. Queue Reconstruction by Height leetcode.com/problems/queue-reconstruction-by-height/ Queue Reconstruction by Height - 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 reconstructQueue(self, people: List[List[int]]) -> List[List[int]]: solution = [] people.sort(key= lambda x : (-x[0],x[1])) for.. 2021. 4. 12.
반응형