shlogg · Early preview
Md Ariful Haque @mah-shamim

One String Swap Can Make Strings Equal In 60 Characters

Return true if two strings can be equal by swapping at most one character in one string. Check if exactly two indices differ and swap would make them equal. Time complexity: O(n).

1790. Check if One String Swap Can Make Strings Equal
Difficulty: Easy
Topics: Hash Table, String, Counting
You are given two strings s1 and s2 of equal length. A string swap is an operation where you choose two indices in a string (not necessarily different) and swap the characters at these indices.
Return true if it is possible to make both strings equal by performing at most one string swap on e*xactly one* of the strings. Otherwise, return false.
Example 1:

Input: s1 = "bank", s2 = "kanb"
Output: true
Explanation: For example, swap the first character with the last character of s2 to make...