# Leetcode 859 - Buddy string

Note:

• Two situations:
• s === goal, only if there are duplicates in them.
• s !== goal, find the unmatched chars and check if they match after one of them being reversed.

Question:

Given two strings s and goal, return true if you can swap two letters in s so the result is equal to goal, otherwise, return false.

Swapping letters is defined as taking two indices i and j (0-indexed) such that i != j and swapping the characters at s[i] and s[j].

For example, swapping at indices 0 and 2 in “abcd“ results in “cbad“.

Example:

Code: