1
# Runtime: 66 ms (Top 24.00%) | Memory: 13.8 MB (Top 70.18%)
2
class Solution:
3
def splitString(self, s: str, last_val: int = None) -> bool:
4
# Base case, remaining string is a valid solution
5
if last_val and int(s) == last_val - 1:
6
return True
7

8
# Iterate through increasingly larger slices of s
9
for i in range(1, len(s)):
10
cur = int(s[:i])
11
# If current slice is equal to last_val - 1, make
12
# recursive call with remaining string and updated last_val
13
if last_val is None or cur == last_val - 1:
14
if self.splitString(s[i:], cur):
15
return True
16

17
return False

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0