일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- Python Implementation
- Python
- iterator
- 컴퓨터의 구조
- Class
- 109. Convert Sorted List to Binary Search Tree
- Generator
- 파이썬
- Protocol
- 운영체제
- 밴픽
- 프로그래머스
- 30. Substring with Concatenation of All Words
- DWG
- concurrency
- Substring with Concatenation of All Words
- data science
- 715. Range Module
- t1
- kaggle
- Convert Sorted List to Binary Search Tree
- shiba
- 315. Count of Smaller Numbers After Self
- 43. Multiply Strings
- Python Code
- LeetCode
- Decorator
- 시바견
- Regular Expression
- attribute
- Today
- Total
목록Computer Science (392)
Scribbling
생각보다는 쉽게 풀린다. class Solution: def isMatch(self, s: str, p: str) -> bool: n = len(p) m = len(s) # matched[i][j]: (i-1)th pattern matches (j-1)th string matched = [[False] * (m+1) for _ in range(n+1)] matched[0][0] = True for j in range(1, m+1): matched[0][j] = False for i in range(1, n+1): if p[i-1] == '*': matched[i][0] = matched[i-1][0] for i in range(1, n+1): for j in range(1, m+1): if p[i-1] ..
1. 웹 브라우저 웹 브라우저는 가상 머신 (Virtual Machine)이다. 웹 브라우저는 복잡한 명령어 집합을 완전히 소프트웨어로 구현한 추상적 컴퓨터이다. 다시 말하자면, 웹 브라우저는 인터프리터에 속한다. 브라우저는 복잡한 애플리케이션인 동시에 소프트웨어로 구현된 프로그래밍 가능한 컴퓨터이다. 브라우저의 개발자 콘솔 (Developer Console)을 떠올릴 수 있다. 1.1. URL (Uniform Resource Locator) 브라우저는 URL을 사용하여 HTTP 프로토콜을 통해 서버에게 문서를 Request 한다. 서버는 문서를 브라우저에 보내고, 브라우저는 문서를 표시한다. 여기서 문서는 HTML / XML 등의 다양한 마크업 언어로 작성될 수 있다. URL은 아래 그림처럼 세 가지 ..
Rotating a matrix 90 degrees clockwise can be achieved just by transposing + mirror reversing. class Solution: def rotate(self, matrix: List[List[int]]) -> None: """ Do not return anything, modify matrix in-place instead. """ m, n = len(matrix), len(matrix[0]) for i in range(m): for j in range(i+1, n): matrix[i][j], matrix[j][i] = matrix[j][i], matrix[i][j] for i in range(m): for j in range(n//2..
1. 어셈블리 언어 (Assembly Language) 컴퓨터는 (혹은 CPU는) 0과 1의 bit로 이루어진 기계어만을 이해할 수 있다. 사람이 기계어를 이용하여 코딩하려면, 무수히 많은 비트 조합을 다 외우고 있어야 할 것이다. 어셈블이 언어는 이러한 비트 조합을 추상화한 언어로, 보다 이해하기 쉬운 니모닉 (Mnemonics)를 통하여 명령어를 작성할 수 있도록 한다. 어셈블러 (Assembler)는 어셈블리 언어로 작성된 코드를 바탕으로 기계어 코드 (Machine Code)로 생성한다. 2. 고수준 언어 (High-Level Language) 고수준 언어는 어셈블리 언어보다 더 높은 추상화 단계에서 작동한다. 고수준 언어의 소스 코드 (Source Code)는 컴파일러 (Compiler)라는 프..
class Solution: def combinationSum(self, candidates: List[int], target: int) -> List[List[int]]: ret = [] arr = [0] self.helper(ret, arr, candidates, target) return ret def helper(self, ret, arr, candidates, target): _sum = sum(arr) if _sum > target: return if _sum == target: ret.append(arr[1:]) return for candidate in candidates: last_input = arr[-1] if candidate >= last_input: next_arr = arr.c..
무지성 포칼포인트의 답... class Solution: def longestValidParentheses(self, s: str) -> int: if not s: return 0 mem = [0] * len(s) stack = [] length = 0 for i in range(len(s)): char = s[i] if char == '(': stack.append(char) length = 0 else: if not stack: length = 0 else: top = stack.pop() if top == '(': length += 2 if i - length >= 0 and s[i-length] == ')': length += mem[i-length] else: length = 0 mem[i] =..
* Note: shift left is the same as multiplying by two. class Solution: def divide(self, dividend: int, divisor: int) -> int: # Overflow if dividend == -2**31 and divisor == -1: return 2**31 - 1 # Positive? positive = (dividend > 0) is (divisor > 0) dividend = abs(dividend) divisor = abs(divisor) res = 0 subtract = divisor while divisor
class Solution: def myPow(self, x: float, n: int) -> float: if n == 0: return 1 if x == 1: return 1 if x == -1: if abs(n) % 2 == 0: return 1 else: return -1 if x == 0: return 0 n_sign = True if n > 0 else False res = 1 count = 0 while count < abs(n): multiplier = x step = 1 while step
1. 데이터 구조와 처리 1.1. 기본 데이터 타입 (Primitive Data Type) - 크기 및 해석이 포함된다. 1.2. 포인터 (Pointer) - 부호가 없는 정수에 불과하나, 메모리 주소로 해석된다. 1.3 배열 1.4. 비트맵 1.5. 문자열 - C 문자열은 따로 길이를 저장하지 않고, 0을 문자열 터미네이터 (String Terminator)로 사용한다. 1.6. 복합 데이터 타입 - 구조체 (Structure): 메모리 정렬을 위해 패딩 (Padding)을 사용한다. - 공용체 (Union): 공용체의 맴버들은 메모리를 공유할 수 있다. 1.7. 단일 연결 리스트 (Linked List) - 데이터의 양이 정해져 있지 않은 경우 잘 작동한다. - 리스트 원소는 메모리에서 아무 위치에나..
O(NK)... from collections import deque, defaultdict class Solution: def findSubstring(self, s: str, words: List[str]) -> List[int]: n = len(s) m = len(words) len_words = len(words[0]) if n < m * len_words: return [] ret = set() ans = defaultdict(int) for word in words: ans[word] += 1 words = set(words) for i in range(0, len_words): comp = defaultdict(int) q = deque([], maxlen=m) while i