Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAdded Anagram.java #1646
Added Anagram.java #1646
Conversation
| Scanner scan=new Scanner(System.in); | ||
| String a=scan.nextLine(); | ||
| String b=scan.nextLine(); | ||
| boolean ana=true; |
rbshealy
Oct 9, 2020
Contributor
Fix indentation
Fix indentation
| for(char c : a.toCharArray()) | ||
| { | ||
| int i=(int)c; | ||
| u[i]++; | ||
| } | ||
| for(char c : b.toCharArray()) | ||
| { | ||
| int i=(int)c; | ||
| v[i]++; | ||
| } |
rbshealy
Oct 9, 2020
Contributor
What is going on here?
What is going on here?
sj056
Oct 10, 2020
Author
- Here i have initialized 2 arrays u and v first for string a and second for b .
- Converted the strings to lowercase.
- Then alternatively, while converting the char of the string to int(we'll get the ASCII value of that character) then
incrementing that particular index of the string by 1(for eg : if char is 'a' then we'll increment the 97th(ASCII value of
a) index of the array).
- We'll follow these steps for both the strings (hence 2 for loops are used) .
- At the end we'll check if both the arrays are equal then the strings are anagram of each other else not.
- Here i have initialized 2 arrays u and v first for string a and second for b .
- Converted the strings to lowercase.
- Then alternatively, while converting the char of the string to int(we'll get the ASCII value of that character) then
incrementing that particular index of the string by 1(for eg : if char is 'a' then we'll increment the 97th(ASCII value of
a) index of the array). - We'll follow these steps for both the strings (hence 2 for loops are used) .
- At the end we'll check if both the arrays are equal then the strings are anagram of each other else not.

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.

Describe your change:
References
Checklist:
Fixes: #{$ISSUE_NO}.