SnowflakeOA #2
Text Score — Prefix + Suffix Match
Estimated MediumStatement and editorial — judging is being prepared
Topics (AI-labelled)Strings
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.
Editorial
Loading solution…