FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
DSA-PS-Java-Programs/ValidAnagram.java at master · codec-akash/DSA-PS-Java-Programs · GitHub
codec-akash
/
DSA-PS-Java-Programs
Public
Notifications
You must be signed in to change notification settings
Fork
32
Star
2
Code
Issues
1
Pull requests
1
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
DSA-PS-Java-Programs
/
ValidAnagram.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
31 lines (29 loc) · 759 Bytes
Breadcrumbs
DSA-PS-Java-Programs
/
ValidAnagram.java
Copy path
File metadata and controls
31 lines (29 loc) · 759 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
/**
* Given two strings s and t , write a function to determine if t is an anagram of s.
* <p>
* Example 1:
* <p>
* Input: s = "anagram", t = "nagaram"
* Output: true
* Example 2:
* <p>
* Input: s = "rat", t = "car"
* Output: false
*/
public
class
ValidAnagram
{
public
boolean
isAnagram
(
String
s
,
String
t
) {
if
(
s
.
length
() >
t
.
length
()) {
return
false
;
}
char
[]
secondWord
=
t
.
toCharArray
();
for
(
char
letter
:
secondWord
) {
if
(!
isContainsLetter
(
s
,
letter
)) {
return
false
;
}
}
return
true
;
}
private
boolean
isContainsLetter
(
String
word
,
char
specificLetter
) {
return
word
.
contains
(
String
.
valueOf
(
specificLetter
));
}
}
Back
|
FazBrowse Home
|
New Git URL