SnowflakeOA #2
Text Score — Prefix + Suffix Match
估计中等评测数据准备中,可先阅读题面
考点(AI 标注)字符串
Given three strings text, prefixString, and suffixString, find:
prefixScore: the longest substring oftextmatching the end ofprefixString.suffixScore: the longest substring oftextmatching the beginning ofsuffixString.
Sum the lengths of the two strings to get the textScore. The substring of text that begins with the matching prefix and ends with matching suffix, and has the highest textScore, is the correct value to return. If there are other substrings with equal textScore, return the lexicographically lowest substring.
Note: if the prefix and suffix overlap, return only the substring of text, not prefix + suffix.