We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6a64a77 commit 0daca30Copy full SHA for 0daca30
Java/valid-anagram.java
@@ -7,8 +7,8 @@
7
* Follow up:
8
* What if the inputs contain unicode characters? How would you adapt your solution to such case?
9
*
10
-* Works for any unicode characters - 128 unicode chars are there.
11
-*
+* Works for any ASCII characters - 128 ASCII chars are there.
+* for unicode chars - 256 chars are there.
12
*/
13
class Solution {
14
@@ -72,7 +72,7 @@ else if(s.isEmpty()){ // empty string check
72
// Time: O(n) | Space: O(1) [because the table's size stays constant no matter how large n is]
73
public boolean isAnagram(String s, String t) {
74
75
- int [] charCount = new int[128];
+ int [] charCount = new int[128]; // take 256 in case of unicode characters.
76
77
for (int i=0; i<s.length(); i++){
78
charCount[s.charAt(i)]++;
0 commit comments