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]
.
0
and 2
in "abcd"
results in "cbad"
.Example 1:
Example 2:
Example 3:
Constraints:
s.length
, goal.length
<= 2 * 104s
and goal
consist of lowercase letters.Marsgoat Dec 2, 2022
Sheep July 3, 2023