Longest common prefix · Compiler

Longest common prefix

Find the longest sequence of letters that starts every word in the list.

Input
The first line contains n (1 <= n <= 100). Each of the next n lines contains one word of 1 to 40 lowercase English letters.
Output
Print the shared prefix on one line. Print NONE if the words have no first letter in common.

Compiler Explorer runs your code when you run or check it.

Loading your exercise draft…