[Huawei OD machine test real questions java, python, c++, jsNode] Anonymous letter (100% pass + review ideas)

  Please modify the code before using it. This code guarantees a 100% pass rate. This article provides four codes of java, python, c++, and jsNode. The review idea is at the end of the article

topic description

There is a segment in the TV series "The Demarcation Line". In order to disclose the details of the case to the police without revealing himself, the male protagonist cut down the words in the newspaper and cut them into an anonymous letter.
Now another whistleblower hopes to learn from this method and use English newspapers to complete the reporting operation.
But in order to increase the confusion of the article, it is only necessary to satisfy the same number of letters in each word, and not to pay attention to the order of each letter.
Explanation: The word on allows substitution by the word no.
The newspaper stands for newspaper, and the anonymous letter stands for anonymousLetter. I would like to ask whether the content of the newspaper can be spelled into an anonymous letter.

enter description

In the first line, enter the content of newspaper, including 1-N character strings, separated by spaces. In the
second line, input the content of anonymousLetter, including 1-N character strings, separated by spaces .

The strings of newspaper and anonymousLetter are composed of lowercase English letters, and each letter can only be used once; the
alphabetical order of each string in the newspaper content can be adjusted arbitrarily, but the integrity of the string must be guaranteed (each string cannot have redundant letters)
1 < N < 100,
1 <= newspaper.length, anonymousLetter.length <= 10^4

output description

Returns true if the newspaper can spell an anonymous letter, otherwise returns false

Example 1 Input and output examples are for tuning only

Guess you like

Origin blog.csdn.net/m0_58177653/article/details/129399526