Class Solution
-
- All Implemented Interfaces:
public final class Solution2839 - Check if Strings Can be Made Equal With Operations I.
Easy
You are given two strings
s1ands2, both of length4, 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 thatj - i = 2, then swap the two characters at those indices in the string.
Return
trueif you can make the stringss1ands2equal, andfalseotherwise.Example 1:
Input: s1 = "abcd", s2 = "cdab"
Output: true
Explanation: We can do the following operations on s1:
Choose the indices i = 0, j = 2. The resulting string is s1 = "cbad".
Choose the indices i = 1, j = 3. The resulting string is s1 = "cdab" = s2.
Example 2:
Input: s1 = "abcd", s2 = "dacb"
Output: false
Explanation: It is not possible to make the two strings equal.
Constraints:
s1.length == s2.length == 4s1ands2consist only of lowercase English letters.
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
Modifier and Type Method Description final BooleancanBeEqual(String s1, String s2)-
-
Method Detail
-
canBeEqual
final Boolean canBeEqual(String s1, String s2)
-
-
-
-