leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

0192.sh (283B)


      1 // original
      2 for word in $(tr ' ' '\n' < words.txt | sort | uniq); do grep -o "\<$word\>" words.txt | wc -l | xargs echo $word; done | sort -k2 -nr
      3 
      4 // using uniq -c instead of counting word by word
      5 cat words.txt | tr -s ' ' '\n' | sort | uniq -c | sort -nr | awk '{ print $2, $1  }'