Pregunta de entrevista de Indeed

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