Skip to content

Commit 328a407

Browse files
committed
2020-07-19
1 parent 67a1893 commit 328a407

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

0312.戳气球/0312-戳气球.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class Solution(object):
2+
def maxCoins(self, nums):
3+
"""
4+
:type nums: List[int]
5+
:rtype: int
6+
"""
7+
if not nums:
8+
return 0
9+
10+
nums = [1] + nums + [1]
11+
n = len(nums)
12+
dp = [[0 for _ in range(n)] for _ in range(n)]
13+
14+
for i in range(n-2, -1, -1):
15+
for j in range(i+1, n):
16+
for k in range(i+1, j):
17+
dp[i][j] = max(dp[i][j], dp[i][k] + nums[i]*nums[k]*nums[j] + dp[k][j])
18+
return dp[0][-1]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class Solution(object):
2+
def repeatedSubstringPattern(self, s):
3+
"""
4+
:type s: str
5+
:rtype: bool
6+
"""
7+
for i in range(0, len(s) - 1):
8+
if s[:i + 1] * (len(s) //(i + 1)) == s:
9+
return True
10+
return False

0 commit comments

Comments
 (0)