FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
java-algorithims/ParindromePermutationString.java at main · faraimtb/java-algorithims · GitHub
This repository was archived by the owner on Dec 7, 2024. It is now read-only.
faraimtb
/
java-algorithims
Public archive
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
java-algorithims
/
ParindromePermutationString.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
41 lines (31 loc) · 1013 Bytes
Breadcrumbs
java-algorithims
/
ParindromePermutationString.java
Copy path
File metadata and controls
41 lines (31 loc) · 1013 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
31
32
33
34
35
36
37
38
39
40
41
package
com
.
ematrix
;
import
java
.
util
.
Arrays
;
public
class
ParindromePermutationString
{
private
boolean
isValid
(
String
S
) {
int
[]
chaSet
=
new
int
[
256
];
int
evenCount
=
0
;
int
oddCount
=
0
;
int
n
=
S
.
length
();
Arrays
.
fill
(
chaSet
,
0
);
for
(
int
i
=
0
;
i
<
n
;
i
++){
if
(
S
.
charAt
(
i
)!=
' '
){
chaSet
[(
int
)
S
.
charAt
(
i
)]++;
}
}
int
odd
=
0
;
for
(
int
i
=
0
;
i
<
256
;
i
++) {
System
.
out
.
print
((
chaSet
[
i
] &
1
));
if
((
chaSet
[
i
] &
1
) ==
1
)
odd
++;
if
(
odd
>
1
)
return
false
;
}
// Return true if odd count is 0 or 1,
return
true
;
}
public
static
void
main
(
String
[]
args
){
ParindromePermutationString
parindromePermutationString
=
new
ParindromePermutationString
();
boolean
result
=
parindromePermutationString
.
isValid
(
"taco cat"
);
System
.
out
.
println
(
"This string is a palindrome "
+
result
);
}
}
Back
|
FazBrowse Home
|
New Git URL