java.lang.Object
g1501_1600.s1585_check_if_string_is_transformable_with_substring_sort_operations.Solution

public class Solution extends Object
1585 - Check If String Is Transformable With Substring Sort Operations.<p>Hard</p> <p>Given two strings <code>s</code> and <code>t</code>, transform string <code>s</code> into string <code>t</code> using the following operation any number of times:</p> <ul> <li>Choose a <strong>non-empty</strong> substring in <code>s</code> and sort it in place so the characters are in <strong>ascending order</strong>. <ul> <li>For example, applying the operation on the underlined substring in <code>&quot;14234&quot;</code> results in <code>&quot;12344&quot;</code>.</li> </ul> </li> </ul> <p>Return <code>true</code> if <em>it is possible to transform <code>s</code> into <code>t</code></em>. Otherwise, return <code>false</code>.</p> <p>A <strong>substring</strong> is a contiguous sequence of characters within a string.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> s = &ldquo;84532&rdquo;, t = &ldquo;34852&rdquo;</p> <p><strong>Output:</strong> true</p> <p><strong>Explanation:</strong> You can transform s into t using the following sort operations: &ldquo;84532&rdquo; (from index 2 to 3) -> &ldquo;84352&rdquo; &ldquo;84352&rdquo; (from index 0 to 2) -> &ldquo;34852&rdquo;</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> s = &ldquo;34521&rdquo;, t = &ldquo;23415&rdquo;</p> <p><strong>Output:</strong> true</p> <p><strong>Explanation:</strong> You can transform s into t using the following sort operations: &ldquo;34521&rdquo; -> &ldquo;23451&rdquo; &ldquo;23451&rdquo; -> &ldquo;23415&rdquo;</p> <p><strong>Example 3:</strong></p> <p><strong>Input:</strong> s = &ldquo;12345&rdquo;, t = &ldquo;12435&rdquo;</p> <p><strong>Output:</strong> false</p> <p><strong>Constraints:</strong></p> <ul> <li><code>s.length == t.length</code></li> <li><code>1 <= s.length <= 10<sup>5</sup></code></li> <li><code>s</code> and <code>t</code> consist of only digits.</li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • isTransformable

      public boolean isTransformable(String s, String t)