Find the longest self-sufficient substring in a given string. A self-sufficient substring cannot be the full string, and no letter in the substring can occur both inside and outside the substring. Return the length of the longest such substring, or 0 if none exists.
Leetcode 3104. Find Longest Self-Contained Substring
Find the longest substring such that every character in that substring has all of its occurrences contained within it (i.e., no character from the substring appears outside it). This reduces to computing each character's first/last index and merging overlapping intervals (or using a two-pointer/scan) to identify the longest valid segment.
Onde essa pergunta já apareceu
Use esses exemplos para entender em que contexto ela costuma cair e adaptar sua prática.
Materiais associados
Nenhum anexo público associado a esta pergunta.
Depois de treinar essa pergunta, vale abrir outras do mesmo tipo e da mesma senioridade para comparar padrões de resposta.
Isso ajuda a sair da memorização de uma resposta só e entrar em repertório real de entrevista.
Continue a preparação com o banco completo
No app você encontra perguntas parecidas, compara empresas e aprofunda essa busca com mais filtros.