O(nlogn) algo

for each postion in paragraph store the frequency of the given words(from
start point to this point) .

now in resultant array you need to two indexes that have >=1 value in the
difference of the frequency of two points.


eg hello hello are you

hello ,you

hello hello are you
1       2      2    2   (freq of hello)
0       0      0    1   (freq of you)

for index 0  we get index 3
for index 1  we get index 3
for index 2 we have no value
for index 3 we have no vale

ans=3-1+1=3

NOTE:INDEX represents word no.

-- 


Reply via email to