Skip to content

Commit 475f7f8

Browse files
authored
Create Check if Strings Can be Made Equal With Operations I.java
1 parent 66a79a0 commit 475f7f8

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class Solution {
2+
public boolean canBeEqual(String s1, String s2) {
3+
boolean firstSwap = (s1.charAt(0) == s2.charAt(0) && s1.charAt(2) == s2.charAt(2)) ||
4+
(s1.charAt(2) == s2.charAt(0) && s1.charAt(0) == s2.charAt(2));
5+
boolean secondSwap = (s1.charAt(1) == s2.charAt(1) && s1.charAt(3) == s2.charAt(3)) ||
6+
(s1.charAt(1) == s2.charAt(3) && s1.charAt(3) == s2.charAt(1));
7+
return firstSwap && secondSwap;
8+
}
9+
}

0 commit comments

Comments
 (0)