FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
LeetCode/PermutationInString.java at master · Orio77/LeetCode · GitHub
Orio77
/
LeetCode
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
LeetCode
/
PermutationInString.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
29 lines (29 loc) · 774 Bytes
Breadcrumbs
LeetCode
/
PermutationInString.java
Copy path
File metadata and controls
29 lines (29 loc) · 774 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
class
Solution
{
public
boolean
checkInclusion
(
String
s1
,
String
s2
) {
if
(
s1
.
length
() >
s2
.
length
()){
return
false
;
}
int
[]
freq
=
new
int
[
26
];
for
(
int
i
=
0
;
i
<
s1
.
length
();
i
++){
freq
[
s1
.
charAt
(
i
) -
'a'
]++;
}
for
(
int
i
=
0
;
i
<
s2
.
length
();
i
++){
freq
[
s2
.
charAt
(
i
) -
'a'
]--;
if
(
i
-
s1
.
length
() >=
0
){
freq
[
s2
.
charAt
(
i
-
s1
.
length
()) -
'a'
]++;
}
if
(
allZeros
(
freq
)){
return
true
;
}
}
return
false
;
}
private
boolean
allZeros
(
int
[]
f
){
for
(
int
i
=
0
;
i
<
26
;
i
++){
if
(
f
[
i
] !=
0
){
return
false
;
}
}
return
true
;
}
}
Back
|
FazBrowse Home
|
New Git URL