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 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*/
1313class 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 )]++;
You can’t perform that action at this time.
0 commit comments