1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/同构字符串 [isomorphic-strings].html
2022-03-29 12:43:11 +08:00

39 lines
1.3 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给定两个字符串&nbsp;<code>s</code>&nbsp;&nbsp;<code>t</code>&nbsp;,判断它们是否是同构的。</p>
<p>如果&nbsp;<code>s</code>&nbsp;中的字符可以按某种映射关系替换得到&nbsp;<code>t</code>&nbsp;,那么这两个字符串是同构的。</p>
<p>每个出现的字符都应当映射到另一个字符,同时不改变字符的顺序。不同字符不能映射到同一个字符上,相同字符只能映射到同一个字符上,字符可以映射到自己本身。</p>
<p>&nbsp;</p>
<p><strong>示例 1:</strong></p>
<pre>
<strong>输入:</strong>s = <code>"egg", </code>t = <code>"add"</code>
<strong>输出:</strong>true
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>s = <code>"foo", </code>t = <code>"bar"</code>
<strong>输出:</strong>false</pre>
<p><strong>示例 3</strong></p>
<pre>
<strong>输入:</strong>s = <code>"paper", </code>t = <code>"title"</code>
<strong>输出:</strong>true</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<p><meta charset="UTF-8" /></p>
<ul>
<li><code>1 &lt;= s.length &lt;= 5 * 10<sup>4</sup></code></li>
<li><code>t.length == s.length</code></li>
<li><code>s</code>&nbsp;&nbsp;<code>t</code>&nbsp;由任意有效的 ASCII 字符组成</li>
</ul>