Pergunta de entrevista da empresa Walmart

Make a function that takes a string and returns the longest substring that does not repeat characters. Try not to brute force it.

Resposta da entrevista

Sigiloso

2 de ago. de 2023

Not sure what it means by "Try not to brute force it", but the way I would do it is to make a For loop that, for every character in the string, leads to another for loop that adds each character to a list until it either reaches the end of the string, or encounters a character already in the list. If the latter, it saves that string and length, and continues on until one such substring reaches the end of the string. Then it compares the substring we saved before to the final substrimg, and returns the longer one