100% Beat Easy Solution
Complexity
Time complexity:O(n)

Space complexity:O(n)
Code
![image.png](https://assets.leetcode.com/users/images/95700d40-9e71-4b81-89f1-47aa885ddea0_1738726821.491551.png)



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

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

# Code
```cpp []
class Solution {
    public:
    bool areAlmostEqual(string s1, string s2) {
        vector<int> diffIdx;
        for (int i = 0; i < s1.length(); ++i){
            if (s1[i] != s2[i]){
                diffIdx.push_back(i);
            }
        }
        return diffIdx.empty() || (diffIdx.size() == 2 && s1[diffIdx[0]] == s2[diffIdx[1]] && s1[diffIdx[1]] == s2[diffIdx[0]]);
    }
};
```
['Hash Table', 'String', 'Counting', 'C++']