FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
LeetCode-Solutions/Python/minimum-window-subsequence.py at master · tehsints/LeetCode-Solutions · GitHub
tehsints
/
LeetCode-Solutions
Public
forked from
kamyu104/LeetCode-Solutions
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
LeetCode-Solutions
/
Python
/
minimum-window-subsequence.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
30 lines (26 loc) · 856 Bytes
Breadcrumbs
LeetCode-Solutions
/
Python
/
minimum-window-subsequence.py
Copy path
File metadata and controls
30 lines (26 loc) · 856 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# Time: O(s * t)
# Space: O(s)
class
Solution
(
object
):
def
minWindow
(
self
,
S
,
T
):
"""
:type S: str
:type T: str
:rtype: str
"""
dp
=
[[
None
for
_
in
xrange
(
len
(
S
))]
for
_
in
xrange
(
2
)]
for
j
,
c
in
enumerate
(
S
):
if
c
==
T
[
0
]:
dp
[
0
][
j
]
=
j
for
i
in
xrange
(
1
,
len
(
T
)):
prev
=
None
dp
[
i
%
2
]
=
[
None
]
*
len
(
S
)
for
j
,
c
in
enumerate
(
S
):
if
prev
is
not
None
and
c
==
T
[
i
]:
dp
[
i
%
2
][
j
]
=
prev
if
dp
[(
i
-
1
)
%
2
][
j
]
is
not
None
:
prev
=
dp
[(
i
-
1
)
%
2
][
j
]
start
,
end
=
0
,
len
(
S
)
for
j
,
i
in
enumerate
(
dp
[(
len
(
T
)
-
1
)
%
2
]):
if
i
>=
0
and
j
-
i
<
end
-
start
:
start
,
end
=
i
,
j
return
S
[
start
:
end
+
1
]
if
end
<
len
(
S
)
else
""
Back
|
FazBrowse Home
|
New Git URL