Company: Publicis Sapient
Difficulty: medium
Maximal TextScore Substring Problem Description Complete the function calculateScore in the editor below. It should return the non-empty substring of text that achieves the highest possible textScore ; when more than one substring ties for the top score, return whichever comes first alphabetically. For any non-empty substring sub taken from text , its textScore is worked out as follows: prefixScore: The length of the longest prefix of sub that is also a suffix of prefixString . suffixScore: The length of the longest suffix of sub that is also a prefix of suffixString . textScore: prefixScore + suffixScore . The function calculateScore has the following parameter(s): text : a string prefixString : a string suffixString : a string Input Format for Custom Testing: Input from stdin will be processed as follows and passed to the function. The first line contains a string text . The next line contains a string prefixString . The last line contains a string suffixString . Examples Example 1: