Company: Amazon_8aug
Difficulty: medium
Retrieve Data Problem Description The Data Science Team at Amazon has lost a piece of data from its database. The team believes the missing data can be recovered from two clues, the strings firstInfo and secondInfo : The missing data is a permutation of the characters of firstInfo (it uses exactly the same letters, each exactly as many times). The missing data is lexicographically greater than secondInfo . The missing data is the lexicographically smallest string that satisfies the two conditions above. A string x is lexicographically smaller than a string y if: x[i] < y[i] at the first position i where x and y differ, or |x| < |y| and x is a prefix of y (where |x| denotes the length of x ). Complete the function retrieveData : given firstInfo and secondInfo , return the missing data. If no such string exists, return "-1" . Input Format Read from standard input. firstInfo secondInfo Line 1 contains the string firstInfo . Line 2 contains the string secondInfo . Output Format Print