mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
38 lines
1.0 KiB
HTML
38 lines
1.0 KiB
HTML
<p>给你两个字符串:<code>ransomNote</code> 和 <code>magazine</code> ,判断 <code>ransomNote</code> 能不能由 <code>magazine</code> 里面的字符构成。</p>
|
||
|
||
<p>如果可以,返回 <code>true</code> ;否则返回 <code>false</code> 。</p>
|
||
|
||
<p><code>magazine</code> 中的每个字符只能在 <code>ransomNote</code> 中使用一次。</p>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>示例 1:</strong></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>ransomNote = "a", magazine = "b"
|
||
<strong>输出:</strong>false
|
||
</pre>
|
||
|
||
<p><strong>示例 2:</strong></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>ransomNote = "aa", magazine = "ab"
|
||
<strong>输出:</strong>false
|
||
</pre>
|
||
|
||
<p><strong>示例 3:</strong></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>ransomNote = "aa", magazine = "aab"
|
||
<strong>输出:</strong>true
|
||
</pre>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>提示:</strong></p>
|
||
|
||
<ul>
|
||
<li><code>1 <= ransomNote.length, magazine.length <= 10<sup>5</sup></code></li>
|
||
<li><code>ransomNote</code> 和 <code>magazine</code> 由小写英文字母组成</li>
|
||
</ul>
|