#C4670. Interleaved Strings Checker
Interleaved Strings Checker
Interleaved Strings Checker
Given three strings, determine whether the third string can be formed by interleaving the characters of the first two strings. In other words, the characters in the first and second strings must appear in the third string in the same order as they appear in their respective strings.
Mathematically, if ( |first| = n_1 ) and ( |second| = n_2 ), then a necessary condition is that ( n_1+n_2=|third| ). The challenge is to verify whether the ordering constraints are also preserved. A dynamic programming approach is recommended to solve this problem.
inputFormat
The input contains exactly three lines from standard input.
Line 1: The string first.
Line 2: The string second.
Line 3: The string third.
outputFormat
Output a single line to standard output containing either "Yes" or "No". "Yes" if the third string is a valid interleaving of the first two strings, otherwise "No".## sample
abc
def
adbcef
Yes