A substring is a continuous part of a string. A subsequence is the part of a string that might be continuous or not but the order of the elements is maintained. For example, given the string atpaaabpabtt, pabt is a substring, while pat is a subsequence.
Now given a string S and a subsequence P, you are supposed to find the shortest substring of S that contains P. If such a solution is not unique, output the left most one.
Input Specification:
Each input file contains one test case which consists of two lines. The first line contains S and the second line P. S is non-

该篇文章介绍了如何在给定字符串S中找到最短的子串,该子串必须包含给定的子序列P。使用C++代码实现的方法通过遍历S并维护一个指针来确定符合条件的最短子串,优先选择左边界更靠左的解。
最低0.47元/天 解锁文章
260

被折叠的 条评论
为什么被折叠?



