Company: opentext_13oct
Difficulty: medium
Longest Common Town Prefix Problem Description There are N people living in a state. In this state, people add 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 starting substring (prefix) and has the maximum length. The names of the people are spelled using English letters and are case insensitive. The output should be in lowercase. Input 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 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 starting substring and has the maximum length. If no such common prefix is found, then do not print anything. Examples Example 1: Input: 5 Rosewood rose rosy rosemarry roshh Output: ros Explanation: "Ros" is the c