전체 글 (115) 썸네일형 리스트형 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.. Greedy algorithm - An algorithmic paradigm that builds up a solution piece by piece, always choosing the next piece that offers the most obvious and immediate benefit. So the problems where choosing locally optimal also leads to global solution are best fit for Greedy. - Fractional Knapsack Problem, the local optimal strategy is to choose the item that has maximum value vs weight ratio. This strategy also leads .. 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 .. 835. Image Overlap leetcode.com/problems/image-overlap/ Image Overlap - 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 largestOverlap(self, A: List[List[int]], B: List[List[int]]) -> int: posa = [] posb = [] for i in range(len(A)) : for j in range(len(A[0])) : if A[i][j] == 1 : p.. 이전 1 2 3 4 5 6 7 ··· 15 다음