Company: opentext_13oct
Difficulty: medium
Longest Common Town Prefix Problem Description There are N people living in a state. In this state every person writes the name of their town immediately before their own first name, so each recorded name starts with the town name and continues with the first name. You are given the N recorded names. The town name is the longest common starting substring (prefix) shared by all N names. Find it. Names are spelled with English letters and are case-insensitive : Rose , ROSE and rose are the same name. Print the town name in lowercase . Every name starts with the same letter (ignoring case), so the town name always has at least one letter. (inferred -- the source prints nothing when N is 0 or when the names share no common prefix; those inputs are excluded so that every test has a non-empty answer.) Function Description Complete the function getTown in the editor. It has the following parameter: String peopleNames[N] : the recorded names, in input order It returns a String : the longest co