Pergunta de entrevista da empresa Indeed

return a substring given maximum length so that the substring ends with a complete word.