Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

README.md

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