Alternating Merge
Imagine two ribbons of characters, and you take one character from the first ribbon, then one from the second. Given strings first_str and second_str, merge them by alternating characters in order. When one string runs out, append the remaining part of the other string.
Примеры
Ввод
"ABCD", "XY"Вывод
"AXBYCD"Ввод
"XY", "ABCD"Вывод
"XAYBCD"Ввод
"AB", "XYZ"Вывод
"AXBYZ"Нужно реализовать
def alternative_string_arrange(first_str: str, second_str: str) -> str:
Теги
stringstwo-pointers
Entre para ver seu histórico de envios
EntrarEntre para usar o AI Mentor
EntrarVisible tests
1
Input
"ABCD", "XY"Expected
"AXBYCD"2
Input
"XY", "ABCD"Expected
"XAYBCD"3
Input
"AB", "XYZ"Expected
"AXBYZ"4
Input
"ABC", ""Expected
"ABC"5
Input
"ab", "ab"Expected
"aabb"6
Input
" ", "XYZ"Expected
" X YZ"Focus radio
Paused · SomaFM · Fluid