[Huawei OD test questions] character matching (java) 100% pass rate [2023 (B volume) 100 points]

character match

topic description

Give you an array of strings.
Each string is composed of lowercase letters
and a character pattern is composed of lowercase letters and . and *.
Identify which strings in the string array can match the character pattern
. Match any single character
* Match 0 or multiple arbitrary characters
To determine whether a string matches, it is necessary to cover the entire string rather than part of the string

enter description

The first line is multiple strings separated by spaces
1 < length of a single string < 100
1 < number of strings < 100
The second line is character pattern
1 <= character pattern length <= 50
No need to consider abnormal scenarios

output description

When the subscripts (starting from 0) of the matched string in the array match
multiple times, the subscripts are in ascending order and separated by commas.
If none of them match, output -1

example one

enter

ab aab abacd
.*

output

0,1,2

Example two

enter

ab aab
a.b

output

Guess you like

Origin blog.csdn.net/weixin_45541762/article/details/132395045