This page is still under construction.

Parts of this page are still being built. What you see may change.

Longest Common Substring

Time limit2sMemory limit512 MB

Summary
Given up to 10 lowercase strings, each up to 100,000 characters, find the length of the longest substring shared by all of them.
Level

Medium7 of 10

Topics
String, Binary search, Hash map, String matching
Solved
No attempts yet

Problem

Given N strings, find the length of the longest substring that appears in all of them.

Input

The first line gives the number of strings N (2 ≤ N ≤ 10). The next N lines each contain one string. The length of a single string is at most 100,000, and each string consists only of lowercase English letters.

Output

Print the length of the longest substring that appears in all the strings.

Examples1

  1. Example 1

    Input
    3
    alsdfkjfjkdsal
    fdjskalajfkdsla
    aaaajfaaaa
    
    Expected output
    2