Pergunta de entrevista da empresa Google

Given a list of strings return the substring representing the longest common prefix

Respostas da entrevista

Sigiloso

14 de mai. de 2011

Consider inserting the strings into a "trie" and keep track of the longest prefix.

6

Sigiloso

4 de abr. de 2011

b/w 2 strings -> the brute force method (comapre one by one until they are not equal). divide and conquer the original problem by finding longest common prefix of every 2 strings, then lcp of the found lcps, and so on....

2

Sigiloso

4 de fev. de 2012

Sort strings first. Then compare each char of n and n+1 keeping track of longest prefix.

1