Java🍵|Beats 100%✅|Easy🔥
Complexity
Code
# Complexity
![image.png](https://assets.leetcode.com/users/images/77fa4568-1f04-49c3-8d99-9e3cb88249bb_1738719689.5246754.png)
![image.png](https://assets.leetcode.com/users/images/5d27e516-d699-4ec2-9461-15810ce5ab26_1738719693.7889717.png)



# Code
```java []
class Solution {
    public boolean areAlmostEqual(String s1, String s2) {
        int count=0;
        int n=s1.length();
        int freq[]=new int[26];
        for(int i=0;i<n;i++){
            if(s1.charAt(i)!=s2.charAt(i)){
                count++;
                freq[s1.charAt(i)-'a']++;
                freq[s2.charAt(i)-'a']--;
            }
        }
        for(int i:freq){
            if(i!=0){
                count++;
            }
        }
        return count==0 || count==2;
    }
}
```
['Hash Table', 'String', 'Counting', 'Java']