3 C++ solutions || Hash table, two-pointer and swap approach
Code\n\n// Solution 1 (Simple swap)\nclass Solution {\npublic:\n    bool areAlmostEqual(string s1, string s2) {\n        vector<int> diff_pos;\n        for(int 
# Code\n```\n// Solution 1 (Simple swap)\nclass Solution {\npublic:\n    bool areAlmostEqual(string s1, string s2) {\n        vector<int> diff_pos;\n        for(int i = 0; i < s1.size(); i++) {\n            if(s1[i] != s2[i])\n                diff_pos.push_back(i);\n            if(diff_pos.size() > 2)\n                return false;\n        }\n        if(diff_pos.empty())\n            return true;\n        if(diff_pos.size() == 2) \n            swap(s1[diff_pos[0]], s1[diff_pos[1]]); \n        return s1 == s2;\n    }\n};\n\n// Solution 2 (Hash table)\nclass Solution {\npublic:\n    bool areAlmostEqual(string s1, string s2) {\n        unordered_map<int, char> mp1, mp2;\n        for(int i=0; i<s1.length(); i++){\n            mp1[i] = s1[i];\n            mp2[i] = s2[i];\n        }\n        int count = 0;\n        char c1, c2;\n        for(int i=0; i<mp1.size(); i++){\n            if(mp1[i] != mp2[i]){\n                if(count){\n                    if(++count == 3)    return false;\n                    if(c1 != mp2[i] || c2 != mp1[i])  return false;\n                }\n                else{\n                    c1 = mp1[i], c2 = mp2[i];\n                    count++;\n                }\n            }\n        }\n        return count==1 ? false : true;\n    }\n};\n\n// Solution 3 (Two-pointer)\nclass Solution {\npublic:\n    bool areAlmostEqual(string s1, string s2) {\n        if(s1 == s2)    return true;\n        int left = 0, right = s1.size()-1;\n        while(s1[left] == s2[left])\n            left++;\n        while(s1[right] == s2[right])\n            right--;\n        swap(s2[right], s2[left]);\n        return s1==s2;\n    }\n};\n```
['Hash Table', 'Two Pointers', 'String', 'C++']