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)/猜数字 [guess-numbers].html
2022-03-29 12:43:11 +08:00

31 lines
1.1 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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>小A 和 小B 在玩猜数字。小B 每次从 1, 2, 3 中随机选择一个小A 每次也从 1, 2, 3 中选择一个猜。他们一共进行三次这个游戏,请返回 小A 猜对了几次?</p>
<p>输入的<code>guess</code>数组为 小A 每次的猜测,<code>answer</code>数组为 小B 每次的选择。<code>guess</code><code>answer</code>的长度都等于3。</p>
<p> </p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>guess = [1,2,3], answer = [1,2,3]
<strong>输出:</strong>3
<strong>解释:</strong>小A 每次都猜对了。</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>guess = [2,2,3], answer = [3,2,1]
<strong>输出:</strong>1
<strong>解释:</strong>小A 只猜对了第二次。</pre>
<p> </p>
<p><strong>限制:</strong></p>
<ol>
<li><code>guess</code> 的长度 = 3</li>
<li><code>answer</code> 的长度 = 3</li>
<li><code>guess</code> 的元素取值为 <code>{1, 2, 3}</code> 之一。</li>
<li><code>answer</code> 的元素取值为 <code>{1, 2, 3}</code> 之一。</li>
</ol>