This is a ruby sample code which finds the longest substring from all the wrods in a text, given the number of occurences