FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
leetcode-study/minimum-window-substring/ekgns33.java at main · DaleStudy/leetcode-study · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
DaleStudy
/
leetcode-study
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
361
Star
155
Code
Issues
75
Pull requests
5
Discussions
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
leetcode-study
/
minimum-window-substring
/
ekgns33.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
30 lines (30 loc) · 725 Bytes
Breadcrumbs
leetcode-study
/
minimum-window-substring
/
ekgns33.java
Copy path
File metadata and controls
30 lines (30 loc) · 725 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
30
class
Solution
{
public
String
minWindow
(
String
s
,
String
t
) {
int
[]
freq
=
new
int
[
128
];
char
[]
str
=
s
.
toCharArray
();
int
minL
=
0
;
int
minLength
=
Integer
.
MAX_VALUE
;
int
l
=
0
,
r
=
0
,
n
=
s
.
length
();
for
(
char
c
:
t
.
toCharArray
()) {
freq
[
c
-
'A'
]++;
}
int
resolved
=
t
.
length
();
while
(
r
<
n
) {
if
(
freq
[
str
[
r
++] -
'A'
]-- >
0
) {
resolved
--;
}
while
(
resolved
==
0
) {
if
(
r
-
l
<
minLength
) {
minL
=
l
;
minLength
=
r
-
l
;
}
if
(
freq
[
str
[
l
] -
'A'
]++ ==
0
) {
resolved
++;
}
l
++;
}
}
if
(
minLength
==
Integer
.
MAX_VALUE
)
return
""
;
return
new
String
(
str
,
minL
,
minLength
);
}
}
Back
|
FazBrowse Home
|
New Git URL