Hi, my solution got wrong answer for this test and I can't figure out why, shouldn't the output be "a" ?
Thanks in advance.
What you are looking for is the longest common prefix. In other words, the longest substring the strings start with in common. While "a" is the longest common substring, "ca" does not start with "a", so it cannot be a prefix, and therefore cannot be the correct answer.
Since one starts with 'c' and the other starts with 'a', only the empty string at the start is in common to the two strings provided.