# Lexicographically largest possible by merging two strings by adding one character at a time

Lexicographically largest possible by merging two strings by adding one character at a time Given two strings S and T, the task is to merge these two strings by adding one character at a time from the beginning of either string to form a resultant string. The resultant string should be lexicographically the largest string that can be formed by merging the strings S and T. Examples:Input: S = “dbcbb”, T = “cdbbb”Output : dcdbcbbbbbInput : S = “geeks“, T = “forgeeks”Output : gforgeekseeksApproach: The simplest idea to solve the problem is to greedily select the first characters from the string which is lexicographically bigger than others. Therefore, Greedy algorithm and Recursion can be used to solve the problem. Follow the steps below to solve the problem: If either of the string lengths is 0, then return S + T as the answer.If S is lexicographically larger than T, then return S + largestMerge(S.substr(1), T).Otherwise, take the first character of T and call the recursive function largestMerge(S, T.substr(1)).Below is the implementation of the above approach:C++  #include using namespace std;  string largestMerge(string s1, string s2){            if (s1.size() == 0 || s2.size() == 0)        return s1 + s2;              if (s1 > s2) {                          return s1 + largestMerge(s1.substr(1), s2);    }                  return s2 + largestMerge(s1, s2.substr(1));}  int main(){        string s1 = “geeks”;    string s2 = “forgeeks”;          cout 