[LeetCode] Cracking the Safe 破解密码

Posted Grandyang

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[LeetCode] Cracking the Safe 破解密码相关的知识,希望对你有一定的参考价值。

 

There is a box protected by a password. The password is n digits, where each letter can be one of the first k digits 0, 1, ..., k-1.

You can keep inputting the password, the password will automatically be matched against the last n digits entered.

For example, assuming the password is "345", I can open it when I type "012345", but I enter a total of 6 digits.

Please return any string of minimum length that is guaranteed to open the box after the entire string is inputted.

Example 1:

Input: n = 1, k = 2
Output: "01"
Note: "10" will be accepted too.

 

Example 2:

Input: n = 2, k = 2
Output: "00110"
Note: "01100", "10011", "11001" will be accepted too.

 

Note:

  1. n will be in the range [1, 4].
  2. k will be in the range [1, 10].
  3. k^n will be at most 4096.

 

s

 

以上是关于[LeetCode] Cracking the Safe 破解密码的主要内容,如果未能解决你的问题,请参考以下文章

lc 753. Cracking the Safe

论文阅读CodeTrans: Towards Cracking the Language of Silicon‘s Code......

论文阅读CodeTrans: Towards Cracking the Language of Silicon‘s Code......

[Cracking the Coding Interview] 4.5 Validate BST

753. Cracking the Safe

753. Cracking the Safe