Company: Publicis Sapient_26march
Difficulty: medium
Find the substring having a maximal textScore Problem Description Given three strings: text , prefixString , and suffixString . You need to find a non-empty substring of text that has the maximal textScore . If multiple substrings have the same maximal textScore , return the lexicographically smallest one. The textScore for a substring is calculated as follows: prefixScore : The length of the longest string P such that P is a suffix of prefixString and P is a prefix of the current substring of text being evaluated. suffixScore : The length of the longest string S such that S is a prefix of suffixString and S is a suffix of the current substring of text being evaluated. textScore = prefixScore + suffixScore . For example, if text = "engine" , prefixString = "raven" , and suffixString = "ginkgo" : For the string "engine": "en" is a suffix of "raven" and a prefix of "engine", so prefixScore = 2 . "eng" is a prefix of "ginkgo" and a suffix of "engine", so suffixScore = 3 . textScore = 2 +