Skip to content

Commit 12570d4

Browse files
committed
Runtime: 129 ms (Top 6.42%) | Memory: 13.9 MB (Top 92.66%)
1 parent c7afcc8 commit 12570d4

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Runtime: 129 ms (Top 6.42%) | Memory: 13.9 MB (Top 92.66%)
12
class Solution(object):
23
def ambiguousCoordinates(self, s):
34
"""
@@ -6,21 +7,21 @@ def ambiguousCoordinates(self, s):
67
"""
78
def _isValidSplit(s):
89
return False if len(s)>1 and re.match('/^[0]+$/',s) else True
9-
10+
1011
def _isValidNum(ipart,fpart):
1112
return False if (len(ipart)>1 and ipart[0]=='0') or (fpart and fpart[-1]=='0') else True
12-
13+
1314
def _splitToNums(s):
1415
rets=[]
1516
if len(s)==1:return [s]
1617
for i in range(1,len(s)+1):
1718
a,b=s[:i],s[i:]
1819
if _isValidNum(a,b):rets.append("%s.%s"%(a,b) if b else "%s"%(a))
19-
return rets
20-
20+
return rets
21+
2122
ans,s=[],s[1:-1]
2223
for i in range(1,len(s)):
2324
a,b=s[:i],s[i:]
2425
if not _isValidSplit(a) or not _isValidSplit(b):continue
2526
for c1,c2 in itertools.product(_splitToNums(a),_splitToNums(b)):ans.append("(%s, %s)"%(c1,c2))
26-
return ans
27+
return ans

0 commit comments

Comments
 (0)