Two Rates Try to Conquer the World

  • 1

    There are two rates trying to control the world. One is clever and the other one is stupid.

    They found a box with 10 digit buttons (0 ~ 9) and the key to control the world is inside the box.

    They know that the password to open the box contains 4 digits (like: 2367), but they don't know what is the correct password. But when they type the correct password, the box will open automatically.

    Now the clever rate (which is also ambitious) plans to open the box. He will give the other rate a long string of digits, and the other one will press the buttons based on that string.

    You need to know that, the box will only store the last four digits that pressed. For example, if stupid rate presses "12345", then the box will get "1234" first, and when the rate presses "5", the box will try "2345".

    So what is the shortest string that can try every possible password?

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.