The Optimal Solution✅|| JAVA✅
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\nO(N^2)\n\n- Space complexity:\nO(N)\n# Code\n```java []\nclass Solution {\n    public boolean canBeEqual(String s1, String s2) {\n        char b[]=s2.toCharArray();\n        for(int i=0;i<s1.length();i++){\n            for(int j=0;j<s2.length();j++){\n                if(s1.charAt(i)==b[j]){\n                   if(j-i==2){\n                    swap(b,i,j);\n                   }\n                }\n            }\n        }\n        boolean res=true;\n        for(int i=0;i<s1.length();i++){\n            if(s1.charAt(i)!=b[i]){\n                res=false;\n                break;\n            }\n        }\n        return res;\n    }\n        public void swap(char b[],int i,int j){\n          char t=b[i];\n          b[i]=b[j];\n          b[j]=t;\n        }\n    }\n```
['String', 'Java']