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

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 ..

https://neetcode.io/problems/minimum-stack?list=neetcode150 NeetCode neetcode.ioclass MinStack: def __init__(self): self.stack = [] self.min_stack = [] def push(self, val: int) -> None: self.stack.append(val) if self.min_stack: min_stack_element = self.min_stack[-1] self.min_stack.append(min(val, min_stack_element)) else: ..

1) Recursive DFSclass Solution: def validPath(self, n: int, edges: List[List[int]], source: int, destination: int) -> bool: if source == destination: return True # Step 1: Build the adjacency list graph = defaultdict(list) # defaultdict is a subclass of Python’s built-in dict that automatically creates a default value if a key is missing. for u, v in edg..

https://neetcode.io/problems/is-palindrome?list=neetcode150 NeetCode neetcode.io class Solution: def isPalindrome(self, s: str) -> bool: ss = '' for c in s: if c.isalnum(): ss+= c.lower() return ss==ss[::-1]ss = ''Initialize an empty string to store the cleaned version of s.if c.isalnum():isalnum() checks if the character is alphanumeric (letter..

https://neetcode.io/problems/top-k-elements-in-list?list=neetcode150 NeetCode neetcode.io class Solution: def topKFrequent(self, nums: List[int], k: int) -> List[int]: m ={} ans =[] for i in nums: if i in m: m[i]+=1 else: m[i] = 1 l = sorted(m.keys(), key=lambda num: m[num], reverse=True) for u in range(k): ans..

Solution 1. Brute-forceclass Solution: def twoSum(self, nums: List[int], target: int) -> List[int]: for i in range(len(nums)): for j in range(i+1, len(nums)): if nums[i] + nums[j] == target: return [i,j]왜 for j in range(i + 1, len(nums)): 를 쓰나요?twoSum 문제의 기본 아이디어는 모든 가능한 숫자 쌍을 검사해서, 합이 target이 되는 경우를 찾는 거예요. 그런데 중복을 피하고, 자기 자신을 두 번 더하는 걸 방지하..

https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string/ class Solution: def removeDuplicates(self, s: str) -> str: stack = [] for c in s: if stack and stack[-1] == c: stack.pop() else: stack.append(c) return ''.join(stack)

def has_all_unique_characters(s): unique_chars = set(s) if len(s) == len(unique_chars): return True else: return False Using SetsSets are collections of unique elements. You can convert a string into a set to get its unique characters.The order of characters is not guaranteed in a set. text = "programming" unique_chars = set(text) print(unique_chars) # Output: {'g'..

https://leetcode.com/problems/jump-game/description/class Solution: def canJump(self, nums: List[int]) -> bool: max_reach = 0 for i in range(len(nums)): if i > max_reach: return False # Current index is unreachable max_reach = max(max_reach, i + nums[i]) # Update the farthest reachable index return True✅ Explanation:max_reach keeps t..

🔗 What Is a Linked List?A linked list is a linear data structure where each element (node) points to the next one in the sequence.Unlike arrays, which store elements in contiguous memory, a linked list connects scattered nodes using pointers. 🧱 Structure of a NodeEach node in a singly linked list has:val: the data (value)next: a reference (or pointer) to the next nodeExample:class ListNode: ..