Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6528be8

Browse files
committed
Create README - LeetHub
1 parentd490e9e commit6528be8

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

‎0843-guess-the-word/README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<h2><ahref="https://leetcode.com/problems/guess-the-word/?envType=study-plan-v2&envId=google-spring-23-high-frequency">843. Guess the Word</a></h2><h3>Hard</h3><hr><p>You are given an array of unique strings <code>words</code> where <code>words[i]</code> is six letters long. One word of <code>words</code> was chosen as a secret word.</p>
2+
3+
<p>You are also given the helper object <code>Master</code>. You may call <code>Master.guess(word)</code> where <code>word</code> is a six-letter-long string, and it must be from <code>words</code>. <code>Master.guess(word)</code> returns:</p>
4+
5+
<ul>
6+
<li><code>-1</code> if <code>word</code> is not from <code>words</code>, or</li>
7+
<li>an integer representing the number of exact matches (value and position) of your guess to the secret word.</li>
8+
</ul>
9+
10+
<p>There is a parameter <code>allowedGuesses</code> for each test case where <code>allowedGuesses</code> is the maximum number of times you can call <code>Master.guess(word)</code>.</p>
11+
12+
<p>For each test case, you should call <code>Master.guess</code> with the secret word without exceeding the maximum number of allowed guesses. You will get:</p>
13+
14+
<ul>
15+
<li><strong><code>&quot;Either you took too many guesses, or you did not find the secret word.&quot;</code></strong> if you called <code>Master.guess</code> more than <code>allowedGuesses</code> times or if you did not call <code>Master.guess</code> with the secret word, or</li>
16+
<li><strong><code>&quot;You guessed the secret word correctly.&quot;</code></strong> if you called <code>Master.guess</code> with the secret word with the number of calls to <code>Master.guess</code> less than or equal to <code>allowedGuesses</code>.</li>
17+
</ul>
18+
19+
<p>The test cases are generated such that you can guess the secret word with a reasonable strategy (other than using the bruteforce method).</p>
20+
21+
<p>&nbsp;</p>
22+
<p><strongclass="example">Example 1:</strong></p>
23+
24+
<pre>
25+
<strong>Input:</strong> secret =&quot;acckzz&quot;, words = [&quot;acckzz&quot;,&quot;ccbazz&quot;,&quot;eiowzz&quot;,&quot;abcczz&quot;], allowedGuesses = 10
26+
<strong>Output:</strong> You guessed the secret word correctly.
27+
<strong>Explanation:</strong>
28+
master.guess(&quot;aaaaaa&quot;) returns -1, because&quot;aaaaaa&quot; is not in wordlist.
29+
master.guess(&quot;acckzz&quot;) returns 6, because&quot;acckzz&quot; is secret and has all 6 matches.
30+
master.guess(&quot;ccbazz&quot;) returns 3, because&quot;ccbazz&quot; has 3 matches.
31+
master.guess(&quot;eiowzz&quot;) returns 2, because&quot;eiowzz&quot; has 2 matches.
32+
master.guess(&quot;abcczz&quot;) returns 4, because&quot;abcczz&quot; has 4 matches.
33+
We made 5 calls to master.guess, and one of them was the secret, so we pass the test case.
34+
</pre>
35+
36+
<p><strongclass="example">Example 2:</strong></p>
37+
38+
<pre>
39+
<strong>Input:</strong> secret =&quot;hamada&quot;, words = [&quot;hamada&quot;,&quot;khaled&quot;], allowedGuesses = 10
40+
<strong>Output:</strong> You guessed the secret word correctly.
41+
<strong>Explanation:</strong> Since there are two words, you can guess both.
42+
</pre>
43+
44+
<p>&nbsp;</p>
45+
<p><strong>Constraints:</strong></p>
46+
47+
<ul>
48+
<li><code>1 &lt;= words.length &lt;= 100</code></li>
49+
<li><code>words[i].length == 6</code></li>
50+
<li><code>words[i]</code> consist of lowercase English letters.</li>
51+
<li>All the strings of <code>wordlist</code> are <strong>unique</strong>.</li>
52+
<li><code>secret</code> exists in <code>words</code>.</li>
53+
<li><code>10 &lt;= allowedGuesses &lt;= 30</code></li>
54+
</ul>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp