1 Pass JAVA solution Beginner Friendly | Beats 100% 0 ms Solution
Intuition0 miss match ----> Equal
1 miss match ----> Not Equal
2 miss match ----> potentially Equal
more than 2  ----> immediately falseApproach
When first miss
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
0 miss match ----> Equal
1 miss match ----> Not Equal
2 miss match ----> potentially Equal
more than 2  ----> immediately false

# Approach
<!-- Describe your approach to solving the problem. -->
- When first miss match if found make ```flag = false```
- Store the miss matched characters of each ```String s1``` and ```String s2``` in ```Char miss1``` and ```Char miss2``` respectively.
- If a second miss match is found:
- compare the ```Char miss1``` with current miss match of ```String   s2``` 
- compare the ```Char miss2``` with current missmatch of ```String s1```
- If both are equal then the Strings are EQUAL

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

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

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