Buddy Strings, by LeetCode
Problem is here: https://leetcode.com/problems/buddy-strings/description/ Given two strings A and B of lowercase letters, return true if and only if we can swap two letters in A so that the result equals B . Example 1: Input: A = "ab" , B = "ba" Output: true Example 2: Input: A = "ab" , B = "ab" Output: false Example 3: Input: A = "aa" , B = "aa" Output: true Example 4: Input: A = "aaaaaaabc" , B = "aaaaaaacb" Output: true Example 5: Input: A = "" , B = "aa" Output: false Note: 0 <= A.length <= 20000 0 <= B.length <= 20000 A and B consist only of lowercase letters. Problem is deceivingly more obnoxious than it looks. Not hard in terms of "algorithms", but rather the different "special" cases need to be thought thru properly. Here they are: Conditions where you know there won't be a solut...