Check if Strings Can be Made Equal With Operations II
You are given two strings s1 and s2, both of length n, consisting of lowercase English letters.
You can apply the following operation on any of the two strings any number of times:
- Choose any two indices
iandjsuch thati < jand the differencej - iis even, then swap the two characters at those indices in the string.
Return true if you can make the strings s1 and s2 equal, and false otherwise.
Example 1
Input
s1 = "abcdba", s2 = "cabdab"Output
trueBy swapping characters in
s1 at indices with even differences, it can be transformed into "cabdab", which equals s2.Example 2
Input
s1 = "abe", s2 = "bea"Output
falseIt is not possible to make the two strings equal.
Constraints
- n == s1.length == s2.length
- 1 <= n <= 10^5
- s1 and s2 consist only of lowercase English letters.