☯C++ Code || O(1) Time Complexity || Detail Explanation☯
\n# Approach\nFirst compare if both string is same or not. if both are same return true.\nOtherwise,\nswap between s1[0] with s1[2] and check both are same or n
\n# Approach\nFirst compare if both string is same or not. if both are same return true.\nOtherwise,\nswap between s1[0] with s1[2] and check both are same or not.\nswap between s1[1] with s1[3] and check both are same or not.\n\nswap between s1[0] with s1[2] && swap between s1[1] with s1[3] and check both are same or not.\n\n# Complexity\n- Time complexity:\n$$O(1)$$\n\n- Space complexity:\n$$O(1)$$\n\n# Code\n```\nclass Solution {\npublic:\n    bool canBeEqual(string s1, string s2) {\n        string str=s1,st=s1;\n        if(s1==s2)\n            return true;\n        bool flag=false;\n        swap(s1[0],s1[2]);\n        swap(str[1],str[3]);\n        swap(st[0],st[2]);\n        swap(st[1],st[3]);\n        return (s1==s2 || str==s2 || st==s2);\n    }\n};\n```
['C++']