O(1) C++| Check 3 Conditions Only
Code\n\nclass Solution {\npublic:\n    bool canBeEqual(string s1, string s2) {\n        // vector<int> v;\n        // for(int i=0;i<s1.size();i++) {\n        //
# Code\n```\nclass Solution {\npublic:\n    bool canBeEqual(string s1, string s2) {\n        // vector<int> v;\n        // for(int i=0;i<s1.size();i++) {\n        //     if(s1[i] != s2[i]) v.push_back(i);\n        // }\n        // if(v.size()%2 != 0) return false;\n        // for(int i=1;i<v.size();i+=2) {\n        //     if(v[i]-v[i-1] == 2 and s1[v[i]] == s2[v[i-1]] and s1[v[i]] == s2[v[i-1]])\n        // }\n        if(s1 == s2)    return true;\n        swap(s1[0],s1[2]);\n        if(s1 == s2)    return true;\n        swap(s1[0],s1[2]);\n        swap(s1[1],s1[3]);\n        if(s1 == s2)    return true;\n        swap(s1[0],s1[2]);\n        if(s1 == s2)    return true;\n        return false;\n    }\n};\n```
['C++']