Pergunta de entrevista da empresa MongoDB

Longest common substring along with largest number of string occurrence in the two given strings, optimised solution.