# 859. Buddy Strings LeetCode Solution | Easy Approach Share:

Buddy Strings 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 1:

```Input: s = "ab", goal = "ba"
Output: true
Explanation: You can swap s = 'a' and s = 'b' to get "ba", which is equal to goal.
```

Example 2:

```Input: s = "ab", goal = "ab"
Output: false
Explanation: The only letters you can swap are s = 'a' and s = 'b', which results in "ba" != goal.
```

Example 3:

```Input: s = "aa", goal = "aa"
Output: true
Explanation: You can swap s = 'a' and s = 'a' to get "aa", which is equal to goal.
```

Constraints:

• `1 <= s.length, goal.length <= 2 * 104`
• `s` and `goal` consist of lowercase letters.

Time: O(n)
Space: O(n)

### C++

`` Will be updated Soon``

### Java

``````
Will be updated Soon``````

### Python

``````  Will be updated Soon
``````

#### Watch Tutorial

Checkout more Solutions here