Skip to content

Commit 0daca30

Browse files
Update valid-anagram.java
1 parent 6a64a77 commit 0daca30

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Java/valid-anagram.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
* Follow up:
88
* What if the inputs contain unicode characters? How would you adapt your solution to such case?
99
*
10-
* Works for any unicode characters - 128 unicode chars are there.
11-
*
10+
* Works for any ASCII characters - 128 ASCII chars are there.
11+
* for unicode chars - 256 chars are there.
1212
*/
1313
class Solution {
1414

@@ -72,7 +72,7 @@ else if(s.isEmpty()){ // empty string check
7272
// Time: O(n) | Space: O(1) [because the table's size stays constant no matter how large n is]
7373
public boolean isAnagram(String s, String t) {
7474

75-
int [] charCount = new int[128];
75+
int [] charCount = new int[128]; // take 256 in case of unicode characters.
7676

7777
for (int i=0; i<s.length(); i++){
7878
charCount[s.charAt(i)]++;

0 commit comments

Comments
 (0)