You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1585\. Check If String Is Transformable With Substring Sort Operations
2
+
3
+
Hard
4
+
5
+
Given two strings `s` and `t`, transform string `s` into string `t` using the following operation any number of times:
6
+
7
+
* Choose a **non-empty** substring in `s` and sort it in place so the characters are in **ascending order**.
8
+
* For example, applying the operation on the underlined substring in `"14234"` results in `"12344"`.
9
+
10
+
Return `true` if _it is possible to transform `s` into `t`_. Otherwise, return `false`.
11
+
12
+
A **substring** is a contiguous sequence of characters within a string.
13
+
14
+
**Example 1:**
15
+
16
+
**Input:** s = "84532", t = "34852"
17
+
18
+
**Output:** true
19
+
20
+
**Explanation:** You can transform s into t using the following sort operations: "84532" (from index 2 to 3) -> "84352" "84352" (from index 0 to 2) -> "34852"
21
+
22
+
**Example 2:**
23
+
24
+
**Input:** s = "34521", t = "23415"
25
+
26
+
**Output:** true
27
+
28
+
**Explanation:** You can transform s into t using the following sort operations: "34521" -> "23451" "23451" -> "23415"
0 commit comments