mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
26 lines
1.1 KiB
HTML
26 lines
1.1 KiB
HTML
<p>Given two strings <code>s</code> and <code>t</code>, <em>determine if they are isomorphic</em>.</p>
|
|
|
|
<p>Two strings <code>s</code> and <code>t</code> are isomorphic if the characters in <code>s</code> can be replaced to get <code>t</code>.</p>
|
|
|
|
<p>All occurrences of a character must be replaced with another character while preserving the order of characters. No two characters may map to the same character, but a character may map to itself.</p>
|
|
|
|
<p> </p>
|
|
<p><strong>Example 1:</strong></p>
|
|
<pre><strong>Input:</strong> s = "egg", t = "add"
|
|
<strong>Output:</strong> true
|
|
</pre><p><strong>Example 2:</strong></p>
|
|
<pre><strong>Input:</strong> s = "foo", t = "bar"
|
|
<strong>Output:</strong> false
|
|
</pre><p><strong>Example 3:</strong></p>
|
|
<pre><strong>Input:</strong> s = "paper", t = "title"
|
|
<strong>Output:</strong> true
|
|
</pre>
|
|
<p> </p>
|
|
<p><strong>Constraints:</strong></p>
|
|
|
|
<ul>
|
|
<li><code>1 <= s.length <= 5 * 10<sup>4</sup></code></li>
|
|
<li><code>t.length == s.length</code></li>
|
|
<li><code>s</code> and <code>t</code> consist of any valid ascii character.</li>
|
|
</ul>
|