Given two strings s and goal, return true if you can swap exactly two letters in s (at two different indices) so that the result equals goal, and false otherwise.
Given two strings s and goal, return true if you can swap exactly two letters in s (at two different indices) so that the result equals goal, and false otherwise.
Example 1:
Input: {"s":"ab","goal":"ba"}
Output: true
Constraints:
1≤s.length,goal.length≤2×104
s and goal consist of lowercase letters.
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"s":"ab","goal":"ba"}
A swap keeps the length, so first compare len(s) = 2 with len(goal) = 2.