Skip to content

Latest commit

 

History

History
25 lines (17 loc) · 434 Bytes

README.md

File metadata and controls

25 lines (17 loc) · 434 Bytes

Buddy strings

This problem was asked by AirBnB.

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

Input: A = "ab", B = "ba"
Output: True

Input: A = "ab", B = "ba"
Output: False

Input: A = "aa", B = "aa"
Output: True

Input: A = "aaaaaaabc", B = "aaaaaaacb"
Output: True

Input: A = "", B = "aa"
Output: False