Skip to content

Commit b850056

Browse files
authored
Create Check if Strings Can be Made Equal With Operations II.java
1 parent 475f7f8 commit b850056

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
class Solution {
2+
public boolean checkStrings(String s1, String s2) {
3+
int[] odd = new int[26];
4+
int[] even = new int[26];
5+
for (int i = 0; i < s1.length(); i++) {
6+
if (i % 2 == 0) {
7+
even[s1.charAt(i) - 'a']++;
8+
even[s2.charAt(i) - 'a']--;
9+
} else {
10+
odd[s1.charAt(i) - 'a']++;
11+
odd[s2.charAt(i) - 'a']--;
12+
}
13+
}
14+
for (int i = 0; i < 26; i++) {
15+
if (odd[i] != 0 || even[i] != 0) {
16+
return false;
17+
}
18+
}
19+
return true;
20+
}
21+
}

0 commit comments

Comments
 (0)