일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
- 코드업
- 파이썬
- gcp
- array
- LeetCode
- 생성형AI
- sql코테
- 리트코드
- 릿코드
- 투포인터
- GenAI
- two-pointer
- Python
- GenerativeAI
- dfs
- 파이썬알고리즘
- stratascratch
- SQL
- codeup
- 니트코드
- nlp
- 자연어처리
- Greedy
- heap
- slidingwindow
- Python3
- Stack
- 파이썬기초100제
- 슬라이딩윈도우
- 알고리즘
- Today
- Total
목록전체 글 (193)
Tech for good

class Solution: def findJudge(self, n: int, trust: List[List[int]]) -> int: # If there's only one person and no trust relationships, that person is the judge if n == 1 and not trust: return 1 # Initialize trust counts trust_scores = [0] * (n+1) for a,b in trust: trust_scores[a] -= 1 # a trusts someone → cannot be the judge ..

https://neetcode.io/problems/linked-list-cycle-detection?list=neetcode150 NeetCode neetcode.ioLinked List (토끼와 거북이 경주 -> 속도가 다르더라도 결국 만나게 된다!)# Definition for singly-linked list.# class ListNode:# def __init__(self, val=0, next=None):# self.val = val# self.next = nextclass Solution: def hasCycle(self, head: Optional[ListNode]) -> bool: if not head or not head.next: ..

https://neetcode.io/problems/merge-two-sorted-linked-lists?list=neetcode150 NeetCode neetcode.io# Definition for singly-linked list.# class ListNode:# def __init__(self, val=0, next=None):# self.val = val# self.next = nextclass Solution: def mergeTwoLists(self, list1: Optional[ListNode], list2: Optional[ListNode]) -> Optional[ListNode]: # Dummy node to simplify the ..

class Solution: def closestMeetingNode(self, edges: List[int], node1: int, node2: int) -> int: def trace_path(start): dist = {} step = 0 while start != -1 and start not in dist: dist[start] = step step += 1 start = edges[start] return dist dist1 = trace_path(node1) dist2 = trace_path(..

BST(Binary Search Tree)# 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 = rightclass Solution: def closestValue(self, root: Optional[TreeNode], target: float) -> int: closest = root.val while root: # Update closest if this node is nearer, ..

Greedy + Adjacency Counting Approachclass Solution: def islandPerimeter(self, grid: List[List[int]]) -> int: # Initialize perimeter perimeter = 0 # Iterate over each cell in the grid for i in range(len(grid)): for j in range(len(grid[0])): # If the cell is land if grid[i][j] == 1: # Add 4 for the c..

Depth-First Search (DFS)class Solution: def floodFill(self, image: List[List[int]], sr: int, sc: int, color: int) -> List[List[int]]: original_color = image[sr][sc] if original_color == color: return image # No need to do anything if the target color is the same rows, cols = len(image), len(image[0]) def dfs(r, c): if (r = row..

class Solution: def minSubsequence(self, nums: List[int]) -> List[int]: nums.sort(reverse=True) totalSum = sum(nums) result = [] current = 0 for num in nums: result.append(num) current += num if current > totalSum - current: break return resultclass Solution: def minSubsequence(self, nums: List[int]) ..

class Solution: def minMovesToSeat(self, seats: List[int], students: List[int]) -> int: students.sort(reverse=True) seats.sort(reverse=True) minMove = 0 for i in range(len(students)): minMove += abs(students[i] - seats[i]) return minMove✅ Why Use abs() (Absolute Value)?The problem asks for the total number of moves to align each student with a sea..

class Solution: def largestOddNumber(self, num: str) -> str: for i in range(len(num)-1, -1, -1): if int(num[i]) % 2 == 1: return ''.join(num[:i+1]) return "" # 64278# i = 3# num = [6, 4, 2, 7, 8]# num[:i] -> [6, 4, 2]# num[:i+1] -> [6, 4, 2, 7] Backward iteration in Pythonrange function is provided with three arguments(N, -1, -1). Use th..