1585. Check If String Is Transformable With Substring Sort Operations Hard
1/**
2 * [1585] Check If String Is Transformable With Substring Sort Operations
3 *
4 * Given two strings s and t, transform string s into string t using the following operation any number of times:
5 *
6 * Choose a non-empty substring in s and sort it in place so the characters are in ascending order.
7 *
8 * For example, applying the operation on the underlined substring in "1<u>4234</u>" results in "1<u>2344</u>".
9 *
10 *
11 *
12 * Return true if it is possible to transform s into t. Otherwise, return false.
13 * A substring is a contiguous sequence of characters within a string.
14 *
15 * Example 1:
16 *
17 * Input: s = "84532", t = "34852"
18 * Output: true
19 * Explanation: You can transform s into t using the following sort operations:
20 * "84<u>53</u>2" (from index 2 to 3) -> "84<u>35</u>2"
21 * "<u>843</u>52" (from index 0 to 2) -> "<u>348</u>52"
22 *
23 * Example 2:
24 *
25 * Input: s = "34521", t = "23415"
26 * Output: true
27 * Explanation: You can transform s into t using the following sort operations:
28 * "<u>3452</u>1" -> "<u>2345</u>1"
29 * "234<u>51</u>" -> "234<u>15</u>"
30 *
31 * Example 3:
32 *
33 * Input: s = "12345", t = "12435"
34 * Output: false
35 *
36 *
37 * Constraints:
38 *
39 * s.length == t.length
40 * 1 <= s.length <= 10^5
41 * s and t consist of only digits.
42 *
43 */
44pub struct Solution {}
45
46// problem: https://leetcode.com/problems/check-if-string-is-transformable-with-substring-sort-operations/
47// discuss: https://leetcode.com/problems/check-if-string-is-transformable-with-substring-sort-operations/discuss/?currentPage=1&orderBy=most_votes&query=
48
49// submission codes start here
50
51impl Solution {
52 pub fn is_transformable(s: String, t: String) -> bool {
53 false
54 }
55}
56
57// submission codes end
58
59#[cfg(test)]
60mod tests {
61 use super::*;
62
63 #[test]
64 fn test_1585() {
65 }
66}
67
Back
© 2025 bowen.ge All Rights Reserved.