Java ✅🤯 - Best Solution
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. --> Check if the strings are already equal or can be made equal by swapping exactly one pair of characters.

# Approach
<!-- Describe your approach to solving the problem. --> Count mismatched positions. If there are exactly two mismatches, check if swapping them makes the strings equal.

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ --> O(n)

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ --> O(1)

# Code
```java []
class Solution {
    public boolean areAlmostEqual(String s1, String s2) {
        int c = 0;
        int l = s1.length();
        int m[] = new int[2];
        int n = 0;
        for(int i=0; i<l; i++){
            if(s1.charAt(i)==s2.charAt(i)){
                c++;
            }
            else if(n<=1){
                m[n] = i;
                n++;
            }
        }
        if(c==l){
            return true;
        }
        else if(c==l-2 && s1.charAt(m[1])==s2.charAt(m[0]) && s1.charAt(m[0])==s2.charAt(m[1])){
            return true;
        }
        else{
            return false;
        }
    }
}
```
['Java']