Skip to content

Commit 9690b39

Browse files
authored
Updated return type for function
1 parent 8ae7c99 commit 9690b39

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

dynamic_programming/palindrome_partitioning.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
"""
1010

1111

12-
def find_minimum_partitions(s):
12+
def find_minimum_partitions(string: str) -> int:
1313
"""
14-
Returns the minimum cuts needed for a palindrome partitioning of s
14+
Returns the minimum cuts needed for a palindrome partitioning of string
1515
1616
>>> find_minimum_partitions("aab")
1717
1
@@ -20,13 +20,13 @@ def find_minimum_partitions(s):
2020
>>> find_minimum_partitions("ababbbabbababa")
2121
3
2222
"""
23-
n = len(s)
23+
n = len(string)
2424
cut = [0 for i in range(n)]
2525
ispalindrome = [[False for i in range(n)] for j in range(n)]
2626
for i in range(n):
2727
mincut = i
2828
for j in range(i + 1):
29-
if s[i] == s[j] and (i - j < 2 or ispalindrome[j + 1][i - 1]):
29+
if string[i] == string[j] and (i - j < 2 or ispalindrome[j + 1][i - 1]):
3030
ispalindrome[j][i] = True
3131
mincut = min(mincut, 0 if j == 0 else (cut[j - 1] + 1))
3232
cut[i] = mincut

0 commit comments

Comments
 (0)