Check if a string can be convert to another by swapping two characters

Table of contents

Introduction into the problemAlgorithmImplementation1. Introduction into the problem

Having two strings s1 and s2 equal in length of size n, you must check if they are equal after you swap any of two different characters. If strings are different on more than just 2 characters it must return false.

Example 1:

Input: s1 = "kanb", s2 = "bank"
Output: true

Example 2:

Input: s1 = "kanban", s2 = "balcan"
Output: false

Example 3:

Input: s1 = "equal", s2 = "equal"
Output: true

2....
 •  0 comments  •  flag
Share on Twitter
Published on July 02, 2022 14:23
No comments have been added yet.