일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- SQL
- 슬라이딩윈도우
- Python3
- 자연어처리
- Python
- dfs
- 리트코드
- slidingwindow
- 파이썬기초100제
- heap
- two-pointer
- 파이썬알고리즘
- LeetCode
- GenAI
- 니트코드
- 알고리즘
- Greedy
- sql코테
- 코드업
- codeup
- stratascratch
- 파이썬
- array
- gcp
- 릿코드
- 투포인터
- 생성형AI
- nlp
- GenerativeAI
- Stack
- Today
- Total
목록전체 글 (193)
Tech for good

1. Linear Searchclass Solution: def search(self, nums: List[int], target: int) -> int: for i in range(len(nums)): if target == nums[i]: return i return -1Time Complexity: O(n)2. Binary SearchBinary Search, Tree -> Narrow down the scope w/ starter, end and middle!There are two ways for a Binary Search.1. Two pointer + while loop2. Recursion2.1. Two point..

# Definition for singly-linked list.# class ListNode:# def __init__(self, val=0, next=None):# self.val = val# self.next = nextclass Solution: def frequenciesOfElements(self, head: Optional[ListNode]) -> Optional[ListNode]: values = [] curr = head while curr: values.append(curr.val) curr = curr.next freq = Counter(values) ..

Solution 1: prev + curr# Definition for singly-linked list.# class ListNode:# def __init__(self, val=0, next=None):# self.val = val# self.next = nextclass Solution: def deleteDuplicates(self, head: Optional[ListNode]) -> Optional[ListNode]: prev = head curr = None if head: curr = head.next while curr: if curr.val ==..

# Definition for singly-linked list.# class ListNode:# def __init__(self, val=0, next=None):# self.val = val# self.next = nextclass Solution: def reorderList(self, head: Optional[ListNode]) -> None: """ Do not return anything, modify head in-place instead. """ # 1. Find the middle of the list (slow & fast pointer) slow = head ..

Solution 1. By using length of head (one pass)# Definition for singly-linked list.# class ListNode:# def __init__(self, val=0, next=None):# self.val = val# self.next = nextclass Solution: def removeNthFromEnd(self, head: Optional[ListNode], n: int) -> Optional[ListNode]: # Step 1: Calculate the total length length = 0 curr = head while curr: ..

1. General while loop & for loop# Definition for singly-linked list.# class ListNode:# def __init__(self, val=0, next=None):# self.val = val# self.next = nextclass Solution: def middleNode(self, head: Optional[ListNode]) -> Optional[ListNode]: length = 0 curr = head while curr: curr = curr.next length += 1 mid = length // 2..

# Definition for singly-linked list.# class ListNode:# def __init__(self, x):# self.val = x# self.next = Noneclass Solution: def getIntersectionNode(self, headA: ListNode, headB: ListNode) -> Optional[ListNode]: passed_a = set() current_a = headA current_b = headB while current_a or current_b: if (current_a == current_b) and (current_a and curre..

# 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: passed = set() current = head while current: if current in passed: return True passed.add(current) current =..

https://neetcode.io/problems/anagram-groups NeetCode neetcode.io class Solution: def groupAnagrams(self, strs: List[str]) -> List[List[str]]: res = {} for word in strs: count = [0] * 26 for w in word: count[ord(w) - ord('a')] += 1 key = tuple(count) # print(key) if key in res: res[key].append(wo..

https://neetcode.io/problems/daily-temperatures?list=neetcode150 NeetCode neetcode.ioApproach 1 -> nest loop (time complexity: O(n^2)) class Solution: def dailyTemperatures(self, temperatures: List[int]) -> List[int]: res = [] # t = temperature[i] for i, t in enumerate(temperatures): j = i+1 while j = temperatures[j]: j+=1 ..