Skip to content

Commit c8189b1

Browse files
committed
Runtime 42 ms (Top 5.0%) | Memory 16.0 MB (Top 10.6%)
1 parent 95fd0da commit c8189b1

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
class Solution:
22
def findOcurrences(self, text: str, first: str, second: str) -> List[str]:
3-
l=text.split()
4-
result=[]
5-
size=len(l)
6-
cur, nxt=0, 1
7-
while(nxt<size):
8-
if l[cur]==first and l[nxt]==second:
9-
if nxt+1<size:
10-
result.append(l[nxt+1])
11-
else:
12-
break
13-
cur+=1
14-
nxt+=1
15-
return result
3+
pattern = r"(?<=\b" + first +" " + second + r" )[a-z]*"
4+
txt = re.findall(pattern,text)
5+
return txt

0 commit comments

Comments
 (0)