Skip to content

Latest commit

 

History

History
141 lines (56 loc) · 2.08 KB

File metadata and controls

141 lines (56 loc) · 2.08 KB

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:

    <li><code>0 &lt;= A.length &lt;= 20000</code></li>
    
    <li><code>0 &lt;= B.length &lt;= 20000</code></li>
    
    <li><code>A</code> and&nbsp;<code>B</code> consist only of lowercase letters.</li>
    

Solutions

Python3

Java

...