Pergunta de entrevista da empresa Qualcomm

Finding a sub string in a string. I gave a correct answer with poor time complexity. He asked me to implement it with lesser time complexity.