Huawei school recruitment test questions - looking for the key key - 2023

Title description:

Xiaoqiang is participating in the "Escape Room" game. The current level requires finding a box that matches the given  password K (consisting of non-repeating lowercase letters in ascending order) , and giving the box number, which is 1~N.

There is a string s in each box . The string is composed of uppercase letters, lowercase letters, numbers, punctuation marks, and spaces. It is necessary to find all the letters in these strings, and arrange the corresponding password strings after ignoring the case , and return the serial number of the box that matches the password

hint:

No more than 1 box that meets the conditions

Enter a description:

The first line is the string of the key, and the second line is the boxes, in an array style, separated by spaces

The number of boxes N satisfies 1<=N<=10000,

The length of s satisfies 0<=s.length<=50,

The password is an ascending string containing only lowercase letters, and there are no repeated letters,

Password K length K.length, 1<=K.length<=26

Output description:

Return the corresponding box number

If there is no lockbox that meets the requirements, return -1

Supplementary note:

The match between the string spelled out by the characters in the box and the password ignores case, and requires an exact match with the password. For example, the password abc matches aBc, but the password abc does not match abcd

 put away

Example 1

enter:

abc
s,sdf134 A2c4b

output:

2

illustrate:

Guess you like

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