Java
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

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

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

# Code
```java []
class Solution {
    public boolean canBeEqual(String s1, String s2) {
         if(s1.equals(s2)){
            return  true;
        }
            StringBuilder builder = new StringBuilder(s1);
        if(!s1.startsWith(String.valueOf(s2.charAt(0)))) {
            for (int i = 0; i < s1.length(); i++) {
                try {
                    int j = i + 2;
                    builder.setCharAt(i, s1.charAt(j));
                    builder.setCharAt(j, s1.charAt(i));
                    if (builder.toString().equals(s2)) {
                        return true;
                    }
                    s1 = s1.replace(s1, builder.toString());
                } catch (Exception e) {
                    continue;
                }
            }
        }
        else {
            for (int i = 1; i < s1.length()-1; i++) {
                try {
                    int j = i + 2;
                    builder.setCharAt(i, s1.charAt(j));
                    builder.setCharAt(j, s1.charAt(i));
                    if (builder.toString().equals(s2)) {
                        return true;
                    }
                    s1 = s1.replace(s1, builder.toString());
                } catch (Exception e) {
                    continue;
                }
            }
        }
        return false;
    }
}


```
['Java']