Longest Common Prefix
Print the longest prefix shared by all N words, or NONE if it is empty.
Input: the first line has N; the next N lines each have one lowercase word.
Output: the longest common prefix, or NONE.
Constraints:
- 2 ≤ N ≤ 100
- 1 ≤ word length ≤ 100
Sample Tests
Input 1
3 flower flow flight
Output 1
fl
Input 2
2 dog car
Output 2
NONE
Discussion (opens after you solve — no spoilers before)
No comments yet.