Practice Lexicographically Smallest Generated String
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Given str1 of length n and str2 of length m, construct the lexicographically smallest lowercase string word of length n + m - 1. For each index i, the length-m substring starting at i must equal str2 when str1[i] is T and must differ from str2 when str1[i] is F. Return word, or the empty string if no valid construction exists.
Source: Lexicographically Smallest Generated String on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
str1 = "TFTF", str2 = "ab"
"ababa"
# Example 2
str1 = "TFTF", str2 = "abc"
""
# Example 3
str1 = "F", str2 = "d"
"a"
Constraints
Related LeetCode Problems
Practice more problems similar to Lexicographically Smallest Generated String.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.