This problem is in Contest(s) below:
Contest 1501:字符串相关算法