![JAR search and dependency download from the Maven repository](/logo.png)
g0101_0200.s0192_word_frequency.script.sh Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of leetcode-in-kotlin Show documentation
Show all versions of leetcode-in-kotlin Show documentation
Kotlin-based LeetCode algorithm problem solutions, regularly updated
# Read from the file words.txt and output the word frequency list to stdout.
# #Medium #Shell #2023_03_02_Time_96_ms_(80.40%)_Space_3.9_MB_(41.71%)
echo -e "$(cat words.txt)" | awk '{for(i=1;i<=NF;i++){if(arr[$i]==0){arr[$i]=1}else{arr[$i]=arr[$i]+1}}}END{for(i in arr) print i, arr[i]}' | sort -k2 -n -r
© 2015 - 2025 Weber Informatics LLC | Privacy Policy