Tuesday, August 01, 2006

Algorithm - Strings

Given two sentences as strings, write an alogrithm (with the least time complexity) to find the number of occurances of each word of string1 in string2.

For Egs:

string1: Cat eats rat.
string2: Tiger belongs to cat family but it's strange that tiger eats cat.

cat - 2
eats - 1
rat - 0

No comments: