Company: Barclays
Difficulty: medium
Find the Town Name as the Longest Common Substring There are N people living in a state. In this state, people concatenate their town name before their first name. Write an algorithm to find the name of the town of the given N people where the name of the town is the common substring and has the maximum length. Input Format The first line of the input consists of an integer size , representing the given number of people ( N ). The second line consists of N space-separated strings representing the first names of the people. Output Format Print a string in lowercase letters representing the name of the town of the given N people where the name of the town is the common substring and has the maximum length. If no such common prefix is found, then do not print anything. Constraints 0 ≤ size ≤ 10 5 0 < len < 10 6 , where len is the length of the string. Note The names of the people are spelled in English letters and are case insensitive. Examples Input: 5 Rosewood rose rosy rosemary r