Double-ended Strings Solution Codeforces Round #710 Div. 3

You are given the strings aa and bb, consisting of lowercase Latin letters. You can do any number of the following operations in any order: if |a|>0|a|>0 (the length of the string aa is greater than zero), delete the first character of the string aa, that is, replace aa with a2a3…ana2a3…an; if |a|>0|a|>0, delete the last character of the string aa, that is, replace aa with a1a2…an−1a1a2…an−1; if |b|>0|b|>0 (the length of the … Read more