Beginners Friendly
\n\n# Complexity\n- Time complexity:O(N)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity:O(N)\n Add your space complexity here, e.g. O(n) \n\n
\n\n# Complexity\n- Time complexity:O(N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(N)\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.equals(s2)) return true;\n        int count=0;\n        Set<Character> set1= new HashSet<>();\n        Set<Character> set2=new HashSet<>();\n\n        for(int i=0;i<s1.length();i++){\n            if(s1.charAt(i)!=s2.charAt(i)){\n                set1.add(s1.charAt(i));\n                set2.add(s2.charAt(i));\n                count++;\n            }\n        }\n        if(count==2 && set1.equals(set2)) return true;\n        return false;\n    }\n}\n```
['Java']