목록medium (17)
취미가 좋다
https://leetcode.com/problems/kth-largest-element-in-an-array/ Kth Largest Element in an Array - 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 Solution import random class Solution: def findKthLargest(self, nums, k): k = len(nums) - k return self.quick(nums, k) def quick(self, nu..
https://leetcode.com/problems/course-schedule-ii/ Course Schedule II - 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 Solution class Solution: def __init__(self): self.ans = [] self.graph = defaultdict(set) self.visit = None def findOrder(self, numCourses: int, prerequisites: List..
https://leetcode.com/problems/implement-trie-prefix-tree/ Implement Trie (Prefix 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 Solution class Trie: def __init__(self): self.dic = {} def insert(self, word): temp = self.dic for c in word: if not temp.get(c): temp[c] = {} te..
https://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 Solution from queue import Queue class Solution: def canFinish(self, numCourses: int, prerequisites: List[List[int]]) -> bool: q = Queue() a2b = {} # a : 조건이 필요한 수업 b2a ..
https://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 Solution class Solution: def __init__(self): self.m = 0 self.n = 0 self.grid = [] self.visit = [] def numIslands(self, grid): self.m = len(grid) self.n = len(grid[0]..
https://leetcode.com/problems/binary-tree-right-side-view/ Binary Tree Right Side View - 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 Solution # Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left ..