Company: Amazon_10sep
Difficulty: medium
Retrieve Missing Data Problem Description The data science team at Amazon has lost part of a dataset. For every lost record they still have two strings, first_info and second_info , and they know that the missing string is: a permutation of the characters of first_info (it uses every character of first_info exactly as many times as it appears there, and no other characters), lexicographically strictly greater than second_info , and the lexicographically smallest string that satisfies conditions 1 and 2. If no permutation of first_info is strictly greater than second_info , the missing data for that record is the string -1 . A string x is lexicographically smaller than a string y if either x[i] < y[i] at the first position i where they differ, or x is a proper prefix of y (for example ab < abc ). Write an SQL query that recovers the missing data for every row of info_data . Table: info_data Column Type Description id INTEGER Unique identifier of the record (primary key) first_info