Tap here to switch tabs
Problem
Submissions

Problem: Largest Merge Of Two Strings

Try to solve the Largest Merge Of Two Strings problem.

Statement

You are given two strings, word1 and word2. You want to construct a string merge of length equal to the combined length of both strings.

While either word1 or word2 is not empty, you can perform one of the following actions:

  • If word1 is not empty, remove the first character from word1 and append it to merge.

  • If word2 is not empty, remove the first character from word2 and append it to merge.

Return the lexicographically largest merge that can be constructed.

Note: A string a is lexicographically larger than a string b of the same length if, at the first position where they differ, the character in a is greater than the corresponding character in b.

Constraints:

  • 1≤1 \leq word1.length, word2.length ≤3000\leq 3000

  • word1 and word2 consist only of lowercase English letters.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Largest Merge Of Two Strings

Try to solve the Largest Merge Of Two Strings problem.

Statement

You are given two strings, word1 and word2. You want to construct a string merge of length equal to the combined length of both strings.

While either word1 or word2 is not empty, you can perform one of the following actions:

  • If word1 is not empty, remove the first character from word1 and append it to merge.

  • If word2 is not empty, remove the first character from word2 and append it to merge.

Return the lexicographically largest merge that can be constructed.

Note: A string a is lexicographically larger than a string b of the same length if, at the first position where they differ, the character in a is greater than the corresponding character in b.

Constraints:

  • 1≤1 \leq word1.length, word2.length ≤3000\leq 3000

  • word1 and word2 consist only of lowercase English letters.