C# 100% Solution without lists!!!
IntuitionYou need to count the number of mismatched characters in the string (there should be 2 or 0 of them) and these characters should also be equal.Approach
# Intuition
You need to count the number of mismatched characters in the string (there should be 2 or 0 of them) and these characters should also be equal.

# Approach
1. If the characters are not equal, I write them in **n** (**n** counts the number of mismatched letters)
1.1. If this is the first substitution (a==' '), then it is necessary to write **s1[i]** and **s2[i]** in **a** and **b**, respectively.
1.2. If this is the second substitution, then you need to check the letters: they must match **b** and **a**.
2. Return whether the number of mismatched characters is 0 or 2 if the loop is completed successfully.

# 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
```csharp []
public class Solution {
    public bool AreAlmostEqual(string s1, string s2) {
        int n = 0;
        char a = ' ', b= ' ';
        for(int i = 0; i<s1.Length; i++){
            if(s1[i]!=s2[i]){
                if(a == ' '){
                    a=s1[i];
                    b = s2[i];
                }
                else{
                    if(s1[i]!=b || s2[i]!=a )return false;
                }
                n ++;
            }         
        }
        return n<=2 && n!=1;
    }
}
```
['C#']