Easiest Solution🥷🏻 | 0ms Runtime 🔥| Beats 100% 🧯| Beginner Friendly💃🏻
IntuitionIf there are exactly two characters mismatch in both the strings, then only we can try to swap and check if we can make the strings equal.ApproachStore
# Intuition
If there are exactly two characters mismatch in both the strings, then only we can try to swap and check if we can make the strings equal.
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
Store the indexes of mismatched characters in a list. If there are more than two characters that mismatch, we can't swap and make the strings equal. If there are exactly two characters that differ in both the strings, we can try to swap them and see if they are same for both strings.
<!-- Describe your approach to solving the problem. -->

# 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) {
        if(s1== s2){
            return true;
        }

        List<int> unequal = new List<int>();
        for(var i = 0; i < s1.Length; i++){
            if(s1[i] != s2[i]){
                unequal.Add(i);
            }
            if(unequal.Count > 2){
                return false;
            }            
        }
        if(unequal.Count == 2){
            int i= unequal[0], j= unequal[1];
            if(s1[i]==s2[j] && s2[i]==s1[j]){
                return true;
            }
        }

        return false;
    }
}
```
['Hash Table', 'String', 'Counting', 'Java', 'C#', 'MS SQL Server']