Skip to content

Commit 90c4e71

Browse files
committed
Do weekly premium
1 parent 03398f8 commit 90c4e71

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

my-submissions/m1055 v1.py

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
class Solution:
2+
def shortestWay(self, source: str, target: str) -> int:
3+
s = t = output = 0
4+
5+
while t < len(target) :
6+
loop = len(source)
7+
8+
while loop >= 0 and source[s] != target[t] :
9+
s += 1
10+
loop -= 1
11+
if s >= len(source) :
12+
output += 1
13+
s -= len(source)
14+
15+
if source[s] != target[t] :
16+
return -1
17+
18+
s += 1
19+
t += 1
20+
if s >= len(source) :
21+
output += 1
22+
s -= len(source)
23+
24+
if s > 0 :
25+
output += 1
26+
27+
return output

my-submissions/m1055 v2.py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution:
2+
def shortestWay(self, source: str, target: str) -> int:
3+
s = output = 0
4+
5+
for t in target :
6+
for _ in repeat(None, len(source)) :
7+
if source[s] == t :
8+
break
9+
s = (s + 1) % len(source)
10+
output += 1
11+
12+
if source[s] != t :
13+
return -1
14+
output += 1
15+
s = (s + 1) % len(source)
16+
17+
return ceil(output / len(source))

0 commit comments

Comments
 (0)