1433. Check If a String Can Break Another String Medium
1/**
2 * [1433] Check If a String Can Break Another String
3 *
4 * Given two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa. In other words s2 can break s1 or vice-versa.
5 * A string x can break string y (both of size n) if x[i] >= y[i] (in alphabetical order) for all i between 0 and n-1.
6 *
7 * Example 1:
8 *
9 * Input: s1 = "abc", s2 = "xya"
10 * Output: true
11 * Explanation: "ayx" is a permutation of s2="xya" which can break to string "abc" which is a permutation of s1="abc".
12 *
13 * Example 2:
14 *
15 * Input: s1 = "abe", s2 = "acd"
16 * Output: false
17 * Explanation: All permutations for s1="abe" are: "abe", "aeb", "bae", "bea", "eab" and "eba" and all permutation for s2="acd" are: "acd", "adc", "cad", "cda", "dac" and "dca". However, there is not any permutation from s1 which can break some permutation from s2 and vice-versa.
18 *
19 * Example 3:
20 *
21 * Input: s1 = "leetcodee", s2 = "interview"
22 * Output: true
23 *
24 *
25 * Constraints:
26 *
27 * s1.length == n
28 * s2.length == n
29 * 1 <= n <= 10^5
30 * All strings consist of lowercase English letters.
31 *
32 */
33pub struct Solution {}
34
35// problem: https://leetcode.com/problems/check-if-a-string-can-break-another-string/
36// discuss: https://leetcode.com/problems/check-if-a-string-can-break-another-string/discuss/?currentPage=1&orderBy=most_votes&query=
37
38// submission codes start here
39
40impl Solution {
41 pub fn check_if_can_break(s1: String, s2: String) -> bool {
42 false
43 }
44}
45
46// submission codes end
47
48#[cfg(test)]
49mod tests {
50 use super::*;
51
52 #[test]
53 fn test_1433() {
54 }
55}
56
Back
© 2025 bowen.ge All Rights Reserved.