mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-13 19:31:42 +08:00
add leetcode problem-cn part3
This commit is contained in:
37
算法题(国内版)/problem (Chinese)/破解保险箱 [cracking-the-safe].html
Normal file
37
算法题(国内版)/problem (Chinese)/破解保险箱 [cracking-the-safe].html
Normal file
@@ -0,0 +1,37 @@
|
||||
<p>有一个需要密码才能打开的保险箱。密码是 <code>n</code> 位数, 密码的每一位是 <code>k</code> 位序列 <code>0, 1, ..., k-1</code> 中的一个 。</p>
|
||||
|
||||
<p>你可以随意输入密码,保险箱会自动记住最后 <code>n</code> 位输入,如果匹配,则能够打开保险箱。</p>
|
||||
|
||||
<p>举个例子,假设密码是 <code>"345"</code>,你可以输入 <code>"012345"</code> 来打开它,只是你输入了 6 个字符.</p>
|
||||
|
||||
<p>请返回一个能打开保险箱的最短字符串。</p>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>示例1:</strong></p>
|
||||
|
||||
<pre><strong>输入:</strong> n = 1, k = 2
|
||||
<strong>输出:</strong> "01"
|
||||
<strong>说明:</strong> "10"也可以打开保险箱。
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>示例2:</strong></p>
|
||||
|
||||
<pre><strong>输入:</strong> n = 2, k = 2
|
||||
<strong>输出:</strong> "00110"
|
||||
<strong>说明: </strong>"01100", "10011", "11001" 也能打开保险箱。
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>提示:</strong></p>
|
||||
|
||||
<ol>
|
||||
<li><code>n</code> 的范围是 <code>[1, 4]</code>。</li>
|
||||
<li><code>k</code> 的范围是 <code>[1, 10]</code>。</li>
|
||||
<li><code>k^n</code> 最大可能为 <code>4096</code>。</li>
|
||||
</ol>
|
||||
|
||||
<p> </p>
|
Reference in New Issue
Block a user