Skip to content

Commit fa86767

Browse files
author
Ihssaneabousshal
committed
Runtime: 85 ms (Top 15.89%) | Memory: 14 MB (Top 5.19%)
1 parent 586a595 commit fa86767

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1+
# Runtime: 85 ms (Top 15.89%) | Memory: 14 MB (Top 5.19%)
12
class Solution:
23
def gcdOfStrings(self, str1: str, str2: str) -> str:
3-
4-
5-
if len(str2) > len(str1):
4+
5+
if len(str2) > len(str1):
66
str1, str2 = str2, str1
7-
7+
88
curr_str2 = str2
9-
while True:
10-
11-
rep = len(str1)//len(curr_str2)
9+
while True:
10+
11+
rep = len(str1)//len(curr_str2)
1212

13-
if curr_str2*rep == str1:
13+
if curr_str2*rep == str1:
1414
return curr_str2
15-
15+
1616
found = False
17-
for i in range(len(curr_str2)-1, 1, -1):
17+
for i in range(len(curr_str2)-1, 1, -1):
1818
try_str2 = curr_str2[:i]
1919
rep2 = len(str2)//len(try_str2)
20-
21-
if try_str2*rep2 == str2:
20+
21+
if try_str2*rep2 == str2:
2222
curr_str2 = try_str2
2323
found = True
2424
break
25-
25+
2626
if not found:
2727
break
28-
return ""
28+
return ""

0 commit comments

Comments
 (0)