Class Solution
-
- All Implemented Interfaces:
public final class Solution1585 - Check If String Is Transformable With Substring Sort Operations\.
Hard
Given two strings
sandt, transform stringsinto stringtusing the following operation any number of times:Choose a non-empty substring in
sand sort it in place so the characters are in ascending order.
Return
trueif it is possible to transformsintot. Otherwise, returnfalse.A substring is a contiguous sequence of characters within a string.
Example 1:
Input: s = "84532", t = "34852"
Output: true
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"
Example 2:
Input: s = "34521", t = "23415"
Output: true
Explanation: You can transform s into t using the following sort operations: "34521" -> "23451" "23451" -> "23415"
Example 3:
Input: s = "12345", t = "12435"
Output: false
Constraints:
s.length == t.length<code>1 <= s.length <= 10<sup>5</sup></code>
sandtconsist of only digits.
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
Modifier and Type Method Description final BooleanisTransformable(String s, String t)-
-
Method Detail
-
isTransformable
final Boolean isTransformable(String s, String t)
-
-
-
-