Company: Barclays_24july
Difficulty: medium
String generation Problem You are given a string S1 of length L1 consisting only of uppercase Latin letters, and a string S2 of length L2 consisting only of the characters 'T' and 'F' . Build a string S of length L1 + L2 - 1 such that, for every index i with 0 <= i < L2 , the substring of S of length L1 that starts at index i (that is, S[i..i+L1-1] , 0-indexed) is equal to S1 if and only if S2[i] is 'T' : if S2[i] = 'T' , that substring must be exactly S1 ; if S2[i] = 'F' , that substring must be different from S1 . Among all strings S that satisfy the condition, print the lexicographically smallest one. If no such string exists, print -1 . Every character of S must be an uppercase Latin letter A - Z . (inferred - the source does not name the alphabet of S ; it is taken to be the same as that of S1 .) A string a is lexicographically smaller than a string b if a is a proper prefix of b , or if at the first position where they differ, a has the letter that comes earlier in the alph