Skip to content

Practice Check If String Is Transformable With Substring Sort Operations

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Hard#1585
LeetCode Problem

Check If String Is Transformable With Substring Sort Operations

Problem Statement

In one operation, select a nonempty contiguous part of s and sort only that part in ascending character order, in place. Return whether repeating this operation any number of times can transform s exactly into t.

Source: Check If String Is Transformable With Substring Sort Operations on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
s = "84532", t = "34852"
Output
true

# Example 2

Input
s = "34521", t = "23415"
Output
true

# Example 3

Input
s = "12345", t = "12435"
Output
false

Constraints

s.length == t.length
1 <= s.length <= 10^5
s and t consist of only digits.

Related LeetCode Problems

Practice more problems similar to Check If String Is Transformable With Substring Sort Operations.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.