Huawei OD machine test - string rearrangement, string rearrangement (Java & JS & Python)

topic description

Given a string s, s includes a number of words separated by spaces, please perform the following processing on s and output:
1. Internal adjustment of words: Re-sort the letters of each word in lexicographical order
2. Adjust the order between words:
1 ) Count the number of occurrences of each word, and arrange in descending order of the number of times
2) The same number of times, sorted in ascending order of word length
3) The number of times and word length are the same, sorted in ascending order of dictionary

Please output the processed string, each word is separated by a space.

enter description

A line of strings, the value range of each character: [a-zA-z0-9] and spaces, the string length range: [1, 1000]

output description

Output the processed string, with each word separated by a space.

Example

enter This is an apple
output an is This aelpp
illustrate none

Guess you like

Origin blog.csdn.net/qfc_128220/article/details/128061871