-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAlmostEquivalentStings.java
More file actions
36 lines (32 loc) · 1.04 KB
/
AlmostEquivalentStings.java
File metadata and controls
36 lines (32 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<<<<<<< HEAD
//2068. Check Whether Two Strings are Almost Equivalent
class Solution {
public boolean checkAlmostEquivalent(String word1, String word2) {
int[] freq1 = new int[26];
int[] freq2 = new int[26];
for(int i=0;i<word1.length();i++){
freq1[word1.charAt(i) - 'a']++;
freq2[word2.charAt(i) - 'a']++;
}
for(int i=0;i<26;i++){
if(Math.abs(freq1[i] - freq2[i]) > 3) return false;
}
return true;
}
=======
//2068. Check Whether Two Strings are Almost Equivalent
class Solution {
public boolean checkAlmostEquivalent(String word1, String word2) {
int[] freq1 = new int[26];
int[] freq2 = new int[26];
for(int i=0;i<word1.length();i++){
freq1[word1.charAt(i) - 'a']++;
freq2[word2.charAt(i) - 'a']++;
}
for(int i=0;i<26;i++){
if(Math.abs(freq1[i] - freq2[i]) > 3) return false;
}
return true;
}
>>>>>>> be6ce0b427078b1421d5dd74adb2300dc02daeec
}