cswork / OA打开练习工作台

SnowflakeOA #2

Text Score — Prefix + Suffix Match

估计中等评测数据准备中,可先阅读题面

考点(AI 标注)字符串

Given three strings text, prefixString, and suffixString, find:

  • prefixScore: the longest substring of text matching the end of prefixString.
  • suffixScore: the longest substring of text matching the beginning of suffixString.

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.