Company: Turing_7aug
Difficulty: medium
Lexicographically Optimal Merging of Two Words Problem Description You are given two words, str1 and str2 . Starting from an empty string result , you repeatedly perform one of the following two operations until both str1 and str2 are empty: Take from str1: append the first character of str1 to the end of result and remove it from str1 . For example, if str1 = "xyz" and result = "a" , after this operation str1 = "yz" and result = "ax" . Take from str2: append the first character of str2 to the end of result and remove it from str2 . For example, if str2 = "pq" and result = "ab" , after this operation str2 = "q" and result = "abp" . An operation can only be performed on a word that is not empty. Every character of both words ends up in result exactly once, so result always has length |str1| + |str2| , and the characters of each word keep their original relative order. Your objective is to construct the lexicographically largest possible result . A string a is lexicographically larger th