FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
java-algorithims/UniqueString.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
/
UniqueString.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
41 lines (35 loc) · 1.08 KB
Breadcrumbs
java-algorithims
/
UniqueString.java
Copy path
File metadata and controls
41 lines (35 loc) · 1.08 KB
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
;
public
class
UniqueString
{
public
boolean
hasUniqueChar
(
String
S
){
int
n
=
S
.
length
();
char
[]
tempS
=
S
.
toCharArray
();
for
(
int
i
=
0
;
i
<
n
;
i
++){
char
c
=
tempS
[
i
];
int
j
=
i
+
1
;
while
(
j
<
n
){
if
(
c
==
tempS
[
j
]){
return
false
;}
j
++;
}
}
return
true
;
}
boolean
isUniqueChars
(
String
str
) {
if
(
str
.
length
() >
128
)
return
false
;
boolean
[]
char_set
=
new
boolean
[
128
];
for
(
int
i
=
0
;
i
<
str
.
length
();
i
++) {
int
val
=
str
.
charAt
(
i
);
System
.
out
.
println
((
int
)
str
.
charAt
(
i
));
if
(
char_set
[
val
]) {
//Already found this char in string
return
false
;
}
char_set
[
val
] =
true
;
}
return
true
;
}
public
static
void
main
(
String
[]
args
){
UniqueString
uniqueString
=
new
UniqueString
();
boolean
result
=
uniqueString
.
isUniqueChars
(
"ADAGJWEV"
);
System
.
out
.
print
(
"Is string unique "
+
result
);
}
}
Back
|
FazBrowse Home
|
New Git URL