You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Here we initialize an array of size 26 where each element corresponds to the frequency of a character.
134
+
int[] freq = newint[26];
135
+
// iterate through both strings, incrementing the frequency of each character in the first string and decrementing the frequency of each character in the second string.
136
+
for(inti=0; i<s.length(); i++){
137
+
intpos1 = s.charAt(i) - 'a';
138
+
intpos2 = s.charAt(i) - 'a';
139
+
freq[pos1]++;
140
+
freq[pos2]--;
141
+
}
142
+
// iterate through the frequency array and check if all the elements are zero, if so return true else false
0 commit comments