You barely have to modify the algorithm. Just store the index of the most
recent occurrence instead of reporting it, then report whatever you have
stored right at the end.


On 2 April 2014 19:25, pawan yadav <[email protected]> wrote:

> Hi All,
> How can we do the following problem in efficient way :
>
> Implement lastindexofastring(String s1,String s2) . If s2 is present
> multiple times return the last index of s2 in s1 , else return -1.
>
> Is KMP applicable for this problem? If yes, then how can we modify KMP
> algo?
>
> Thanks,
> Pawan.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].

Reply via email to