2839. Check if Strings Can be Made Equal With Operations I Easy

@problem@discussion
#String



1/**
2 * [2839] Check if Strings Can be Made Equal With Operations I
3 *
4 * You are given two strings s1 and s2, both of length 4, consisting of lowercase English letters.
5 * You can apply the following operation on any of the two strings any number of times:
6 * 
7 * 	Choose any two indices i and j such that j - i = 2, then swap the two characters at those indices in the string.
8 * 
9 * Return true if you can make the strings s1 and s2 equal, and false otherwise.
10 *  
11 * <strong class="example">Example 1:
12 * 
13 * Input: s1 = "abcd", s2 = "cdab"
14 * Output: true
15 * Explanation: We can do the following operations on s1:
16 * - Choose the indices i = 0, j = 2. The resulting string is s1 = "cbad".
17 * - Choose the indices i = 1, j = 3. The resulting string is s1 = "cdab" = s2.
18 * 
19 * <strong class="example">Example 2:
20 * 
21 * Input: s1 = "abcd", s2 = "dacb"
22 * Output: false
23 * Explanation: It is not possible to make the two strings equal.
24 * 
25 *  
26 * Constraints:
27 * 
28 * 	s1.length == s2.length == 4
29 * 	s1 and s2 consist only of lowercase English letters.
30 * 
31 */
32pub struct Solution {}
33
34// problem: https://leetcode.com/problems/check-if-strings-can-be-made-equal-with-operations-i/
35// discuss: https://leetcode.com/problems/check-if-strings-can-be-made-equal-with-operations-i/discuss/?currentPage=1&orderBy=most_votes&query=
36
37// submission codes start here
38
39impl Solution {
40    pub fn can_be_equal(s1: String, s2: String) -> bool {
41        false
42    }
43}
44
45// submission codes end
46
47#[cfg(test)]
48mod tests {
49    use super::*;
50
51    #[test]
52    fn test_2839() {
53    }
54}
55


Back
© 2025 bowen.ge All Rights Reserved.