일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 파이썬
- 시바견
- concurrency
- 715. Range Module
- LeetCode
- Generator
- 밴픽
- Regular Expression
- 30. Substring with Concatenation of All Words
- Decorator
- 컴퓨터의 구조
- 43. Multiply Strings
- 315. Count of Smaller Numbers After Self
- 운영체제
- Class
- Convert Sorted List to Binary Search Tree
- t1
- attribute
- Python Code
- DWG
- Python
- Python Implementation
- iterator
- kaggle
- Protocol
- shiba
- data science
- Substring with Concatenation of All Words
- 109. Convert Sorted List to Binary Search Tree
- 프로그래머스
Archives
- Today
- Total
Scribbling
LeetCode: 131. Palindrome Partitioning 본문
class Solution:
def partition(self, s: str) -> List[List[str]]:
self.ret = []
self.dfs(s, [])
return self.ret
def dfs(self, s, path):
if not s:
self.ret.append(path)
return
for i in range(1, len(s)+1):
first, second = s[:i], s[i:]
if self.is_Palindromic(first):
self.dfs(second, path+[first])
def is_Palindromic(self, s):
return s == s[::-1]
'Computer Science > Coding Test' 카테고리의 다른 글
LeetCode: 300. Longest Increasing Subsequence (0) | 2021.11.15 |
---|---|
LeetCode: 132. Palindrome Partitioning II (0) | 2021.11.13 |
LeetCode: 146. LRU Cache (0) | 2021.11.11 |
LeetCode: 130. Surrounded Regions (0) | 2021.11.10 |
LeetCode: 129. Sum Root to Leaf Numbers (0) | 2021.11.10 |