runtime 1ms 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:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public boolean areAlmostEqual(String s1, String s2) {\n        if (s1.compareTo(s2) == 0) return true;\n        int first = -1, second = -1;\n        for (int i = 0; i < s1.length(); i++) {\n            if (s1.charAt(i) != s2.charAt(i)) {\n                if (first == -1) first = i;\n                else if (second == -1) second = i;\n                else return false;\n            }\n        }\n        if (first == -1 || second == -1) return false;\n        return s1.charAt(first) == s2.charAt(second) &&\n            s1.charAt(second) == s2.charAt(first);\n    }\n}\n```
['Java']