mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 11:43:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			53 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			53 lines
		
	
	
		
			2.0 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 class="example">Example 1:</strong></p>
 | 
						|
 | 
						|
<div class="example-block">
 | 
						|
<p><strong>Input:</strong> <span class="example-io">s = "egg", t = "add"</span></p>
 | 
						|
 | 
						|
<p><strong>Output:</strong> <span class="example-io">true</span></p>
 | 
						|
 | 
						|
<p><strong>Explanation:</strong></p>
 | 
						|
 | 
						|
<p>The strings <code>s</code> and <code>t</code> can be made identical by:</p>
 | 
						|
 | 
						|
<ul>
 | 
						|
	<li>Mapping <code>'e'</code> to <code>'a'</code>.</li>
 | 
						|
	<li>Mapping <code>'g'</code> to <code>'d'</code>.</li>
 | 
						|
</ul>
 | 
						|
</div>
 | 
						|
 | 
						|
<p><strong class="example">Example 2:</strong></p>
 | 
						|
 | 
						|
<div class="example-block">
 | 
						|
<p><strong>Input:</strong> <span class="example-io">s = "foo", t = "bar"</span></p>
 | 
						|
 | 
						|
<p><strong>Output:</strong> <span class="example-io">false</span></p>
 | 
						|
 | 
						|
<p><strong>Explanation:</strong></p>
 | 
						|
 | 
						|
<p>The strings <code>s</code> and <code>t</code> can not be made identical as <code>'o'</code> needs to be mapped to both <code>'a'</code> and <code>'r'</code>.</p>
 | 
						|
</div>
 | 
						|
 | 
						|
<p><strong class="example">Example 3:</strong></p>
 | 
						|
 | 
						|
<div class="example-block">
 | 
						|
<p><strong>Input:</strong> <span class="example-io">s = "paper", t = "title"</span></p>
 | 
						|
 | 
						|
<p><strong>Output:</strong> <span class="example-io">true</span></p>
 | 
						|
</div>
 | 
						|
 | 
						|
<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>
 |