0/leetcode (18) 썸네일형 리스트형 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: n = len(gas) total = current = 0 start = 0 for i in range(n) : amount = gas[i] - cost[i] total += a.. 416. Partition Equal Subset Sum leetcode.com/problems/partition-equal-subset-sum/ Partition Equal Subset Sum - 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 # Brute Force class Solution: def canPartition(self, nums: List[int]) -> bool: total = sum(nums) if total % 2 : return False self.memo = {} return self.dfs.. 784. Letter Case Permutation leetcode.com/problems/letter-case-permutation/ Letter Case Permutation - 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 letterCasePermutation(self, S: str) -> List[str]: output = [""] for i in range(len(S)) : curr = [] for j in range(len(output)) : if S[i].isal.. 55. Jump Game leetcode.com/problems/jump-game/ Jump Game - 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 canJump(self, nums: List[int]) -> bool: n = len(nums) i = 0 farthest = nums[0] while i < n and i = n-1 207. Course Schedule leetcode.com/problems/course-schedule/ Course Schedule - 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 import collections class Solution: def canFinish(self, numCourses: int, prerequisites: List[List[int]]) -> bool: indegrees = [0]*numCourses graph = defaultdict(list) for u, v in.. 41. First Missing Positive leetcode.com/problems/first-missing-positive/ First Missing Positive - 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 firstMissingPositive(self, nums: List[int]) -> int: if 1 not in nums : return 1 n = len(nums) for i in range(n) : if nums[i] n : nums[i] = 1 fo.. 988. Smallest String Starting From Leaf leetcode.com/problems/smallest-string-starting-from-leaf/ Smallest String Starting From Leaf - 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 = l.. 16. 3Sum Closest leetcode.com/problems/3sum-closest/ 3Sum Closest - 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 threeSumClosest(self, nums: List[int], target: int) -> int: diff = float('inf') n = len(nums) nums.sort() for i in range(n-2) : l, r = i+1, n-1 while l < r : curr .. 이전 1 2 3 다음