2019獨角獸企業重金招聘Python工程師標準>>>
Word Frequency(https://leetcode.com/problems/word-frequency/description/)
Example:
Assume that?words.txt
?has the following content:
the day is sunny the the the sunny is is
Your script should output the following, sorted by descending frequency:
the 4 is 3 sunny 2 day 1
然后來看看強大的 awk
awk -vRS='( |\n)+' '{a[$0]++}END{for(i in a)m[a[i]]=i;i=asort(a);for(;i;)print m[a[i]],a[i--]}' words.txt
?
?
?