Posts

Special String

Special String: Consider the string of infinite length obtained by repeating  abcdefghijklmnopqrstuvwxyz  infinitely many times. That is, it looks like  abc...xyzabc...xyzabc... Let string  B B  be the prefix of this string of length  M M . For example, if  M = 6 M = 6 ,  B = B =   abcdef if  M = 29 M = 29 ,  B = B =   abcdefghijklmnopqrstuvwxyzabc Vedansh calls a string  X X  special if it contains  B B  as a  substring . Formally,  X X  is special if for some  1 ≤ L ≤ R ≤ | X | 1 ≤ L ≤ R ≤ | X | ,  X L … R = B X L … R = B . Vedansh has string  S S  of length  N N  (consisting of lowercase Latin letters only). He wants to convert  S S  into a special string. To do so he can perform the following operation: Pick an  i i  such that  1 ≤ i ≤ N 1 ≤ i ≤ N  and delete  S i S i . The remaining parts of  S S  are concatenated....