File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change 7
7
* Follow up:
8
8
* What if the inputs contain unicode characters? How would you adapt your solution to such case?
9
9
*
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.
12
12
*/
13
13
class Solution {
14
14
@@ -72,7 +72,7 @@ else if(s.isEmpty()){ // empty string check
72
72
// Time: O(n) | Space: O(1) [because the table's size stays constant no matter how large n is]
73
73
public boolean isAnagram (String s , String t ) {
74
74
75
- int [] charCount = new int [128 ];
75
+ int [] charCount = new int [128 ]; // take 256 in case of unicode characters.
76
76
77
77
for (int i =0 ; i <s .length (); i ++){
78
78
charCount [s .charAt (i )]++;
You can’t perform that action at this time.
0 commit comments