Company: Turing_24may
Difficulty: medium
Lexicographically Optimal Merging of Two Words Problem Description You are given two strings, str1 and str2 , made up of lowercase English letters. You build a third string, result , which starts out empty. Until both str1 and str2 are empty, you repeatedly perform exactly one of the following two operations: Take from str1 : append the first character of str1 to result and remove it from str1 . For example, if str1 = "xyz" and result = "a" , then after this operation str1 = "yz" and result = "ax" . Take from str2 : append the first character of str2 to result and remove it from str2 . For example, if str2 = "pq" and result = "ab" , then after this operation str2 = "q" and result = "abp" . Every character of str1 and every character of str2 therefore ends up in result , and the characters that came from the same input string keep their original relative order. result always has length |str1| + |str2| . Your objective is to choose the operations so that result is the lexicographically l