Huawei school recruitment test questions - looking for password - 2023

Title description:

Xiao Wang is playing a big game, and there is a level that needs to enter a password to pass. The conditions for obtaining the password are as follows: in a password book, each page has a password composed of 26 lowercase letters, and the passwords of each page are different. It is necessary to find such a longest password from the code book. Starting from the end of it, the new password obtained by removing one digit in turn also exists in the codebook. Please output the passwords that meet the requirements. If there are multiple passwords that meet the requirements, return the password with the largest dictionary order. Returns an empty string if there is no matching password.

Enter a description:

The codebook consists of an array of strings, and different elements are separated by spaces. Each element represents the password of each page of the codebook.

Output description:

a string

Supplementary note:

1 <= number of pages of codebook <= 105

1 <= length of password per page <= 105

Example 1

enter:

h he hel hell hello

output:

hello

illustrate:

"hello" is removed from the end to get "hell", "hel", "he" and "h" all exist in the codebook.

Example 2

enter:

b eredderd bw bww bwwl bwwlm bwwln

output:

bwwln

illustrate:

Both "bwwlm " and "bwwln" are removed from the end to obtain passwords that exist in the codebook. but

Guess you like

Origin blog.csdn.net/2301_76848549/article/details/132255376