All challenges
mediumstrings 10 XP per passing test

Longest Common Prefix

Problem

Given a list of strings, find the longest common prefix. The input is a list of strings, one per line. The output is a string, the longest common prefix, which is printed to STDOUT. If there is no common prefix, print an empty string. For example, if the input is: apple apply apricot the output should be: appe
(run your code to see output)
Advertisement
Sponsored