102. Longest Common Prefix

Acceptance — 0 accepted 0 submissions

Easy
Strings
No companies listed
A phone's autocomplete suggests the longest beginning shared by all the words you've typed before.

Given n words, find their longest common prefix. If they share no common beginning, print None.

Input Format
The first line has n.
Each of the next n lines has one lowercase word.

Output Format
Print the longest common prefix, or None.

Constraints
• 1 ≤ n ≤ 200
• 1 ≤ word length ≤ 200

Example 1

Input
3
flower
flow
flight
Output
fl

Explanation All three start with fl.

Example 2

Input
3
dog
racecar
car
Output
None

Explanation No common first letter.

Example 3

Input
1
bashabyte
Output
bashabyte

Explanation With one word, the whole word is the prefix.

Acceptance —
Accepted 0
Submissions 0
Auto-save
Saved Ln 1, Col 1
Submit a solution to see its status here.
Input
Expected Output
fl
No results yet
Run your code to test it against the sample cases.
Problem List