给定一个字符串和一个字符串列表,用相应的字符串填充输入字符串中的所有空格。
输入输出
输入字符串仅包含字母字符,空格和下划线。它是非空的,并且不以下划线开头。换句话说,输入字符串与正则表达式匹配^[a-z A-Z]([a-z A-Z_]*[a-z A-Z])?$
输入列表中的每个字符串都是非空的,并且仅包含字母数字字符和空格。换句话说,它们匹配正则表达式^[a-z A-Z]+$
。
空白是下划线(_
)的连续序列,下划线()之前或之后都没有。
输入字符串包含n
一些正整数的空格n
,字符串列表恰好包含n
字符串。
通过将k
输入字符串中的每个-th空格替换为输入字符串k
列表中的-th字符串来获得输出。
例
给定一个输入字符串"I like _____ because _______ _____ing"
和一个字符串列表["ice cream", "it is", "satisfy"]
,我们可以找到如下输出:
- 第一个空格紧随其后
"like "
。我们"ice cream"
用来填充它"I like ice cream because ______ _____ing"
。 - 第二个空格紧随其后
"because "
。我们"it is"
用来填充它"I like ice cream because it is _____ing"
。 - 第三个空格紧随其后
"is "
。我们"satisfy"
用来填充它"I like ice cream because it is satisfying"
。
我们输出最后一个字符串"I like ice cream because it is satisfying"
。
测试用例
input string, input list => output
"Things _____ for those who ____ of how things work out _ Wooden",["work out best","make the best","John"] => "Things work out best for those who make the best of how things work out John Wooden"
"I like _____ because _______ _____ing",["ice cream","it is","satisfy"] => "I like ice cream because it is satisfying"
"If you are ___ willing to risk _____ you will ha_o settle for the ordi_____Jim ______n",["not","the usual","ve t","nary ","Roh"] => "If you are not willing to risk the usual you will have to settle for the ordinary Jim Rohn"
"S____ is walking from ____ to ____ with n_oss of ___ W_____ Churchill",["uccess","failure","failure","o l","enthusiasm","inston"] => "Success is walking from failure to failure with no loss of enthusiasm Winston Churchill"
"If_everyone_is_thinking ____ ____ somebody_isnt_thinking G____e P____n",[" "," "," ","alike","then"," "," ","eorg","atto"] => "If everyone is thinking alike then somebody isnt thinking George Patton"
"Pe_________e __say ____motivation does__ last Well___her doe_ bathing____thats why we rec____nd it daily _ __________lar",["opl","often ","that ","nt"," neit","s"," ","omme","Zig","Zig"] => "People often say that motivation doesnt last Well neither does bathing thats why we recommend it daily Zig Ziglar"