| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- 컴퓨터의 구조
- 시바견
- 715. Range Module
- Class
- Protocol
- Convert Sorted List to Binary Search Tree
- data science
- Generator
- 315. Count of Smaller Numbers After Self
- 30. Substring with Concatenation of All Words
- 밴픽
- iterator
- shiba
- t1
- 43. Multiply Strings
- 파이썬
- DWG
- 109. Convert Sorted List to Binary Search Tree
- 프로그래머스
- 운영체제
- Regular Expression
- concurrency
- LeetCode
- Substring with Concatenation of All Words
- Decorator
- attribute
- Python
- kaggle
- Python Code
- Python Implementation
Archives
- Today
- Total
Scribbling
44. Wildcard Matching 본문
생각보다는 쉽게 풀린다.
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] == '*':
matched[i][j] = matched[i][j-1] or matched[i-1][j]
elif p[i-1] == '?':
matched[i][j] = matched[i-1][j-1]
else:
matched[i][j] = matched[i-1][j-1] and p[i-1] == s[j-1]
return matched[n][m]'Computer Science > Coding Test' 카테고리의 다른 글
| 37. Sudoku Solver (0) | 2021.09.06 |
|---|---|
| 36. Valid Sudoku (0) | 2021.09.06 |
| LeetCode: 48. Rotate Image (0) | 2021.09.05 |
| 39. Combination Sum (0) | 2021.09.04 |
| 32. Longest Valid Parentheses (0) | 2021.09.04 |