2840. Check if Strings Can be Made Equal With Operations II Medium

@problem@discussion
#Hash Table#String#Sorting



1/**
2 * [2840] Check if Strings Can be Made Equal With Operations II
3 *
4 * You are given two strings s1 and s2, both of length n, 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 i < j and the difference j - i is even, 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 = "abcdba", s2 = "cabdab"
14 * Output: true
15 * Explanation: We can apply the following operations on s1:
16 * - Choose the indices i = 0, j = 2. The resulting string is s1 = "cbadba".
17 * - Choose the indices i = 2, j = 4. The resulting string is s1 = "cbbdaa".
18 * - Choose the indices i = 1, j = 5. The resulting string is s1 = "cabdab" = s2.
19 * 
20 * <strong class="example">Example 2:
21 * 
22 * Input: s1 = "abe", s2 = "bea"
23 * Output: false
24 * Explanation: It is not possible to make the two strings equal.
25 * 
26 *  
27 * Constraints:
28 * 
29 * 	n == s1.length == s2.length
30 * 	1 <= n <= 10^5
31 * 	s1 and s2 consist only of lowercase English letters.
32 * 
33 */
34pub struct Solution {}
35
36// problem: https://leetcode.com/problems/check-if-strings-can-be-made-equal-with-operations-ii/
37// discuss: https://leetcode.com/problems/check-if-strings-can-be-made-equal-with-operations-ii/discuss/?currentPage=1&orderBy=most_votes&query=
38
39// submission codes start here
40
41impl Solution {
42    pub fn check_strings(s1: String, s2: String) -> bool {
43        false
44    }
45}
46
47// submission codes end
48
49#[cfg(test)]
50mod tests {
51    use super::*;
52
53    #[test]
54    fn test_2840() {
55    }
56}
57


Back
© 2025 bowen.ge All Rights Reserved.