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)/宝石与石头 [jewels-and-stones].html
2022-03-29 12:43:11 +08:00

30 lines
1014 B
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>jewels</code>&nbsp;代表石头中宝石的类型,另有一个字符串 <code>stones</code> 代表你拥有的石头。&nbsp;<code>stones</code>&nbsp;中每个字符代表了一种你拥有的石头的类型,你想知道你拥有的石头中有多少是宝石。</p>
<p>字母区分大小写,因此 <code>"a"</code><code>"A"</code> 是不同类型的石头。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>jewels = "aA", stones = "aAAbbbb"
<strong>输出:</strong>3
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>jewels = "z", stones = "ZZ"
<strong>输出:</strong>0<strong>
</strong></pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;=&nbsp;jewels.length, stones.length &lt;= 50</code></li>
<li><code>jewels</code><code>stones</code> 仅由英文字母组成</li>
<li><code>jewels</code> 中的所有字符都是 <strong>唯一的</strong></li>
</ul>