题目: 有两个数组,a1,a2, 返回一个数组r,r中保存的元素为a1中的字符串是a2中字符串的子集的部分。
Given two arrays of strings
a1
anda2
return a sorted arrayr
in lexicographical order of the strings ofa1
which are substrings of strings ofa2
.#Example 1:
a1 = ["arp", "live", "strong"]
a2 = ["lively", "alive", "harp", "sharp", "armstrong"]
returns
["arp", "live", "strong"]
#Example 2:
a1 = ["tarp", "mice", "bull"]
a2 = ["lively", "alive", "harp", "sharp", "armstrong"]
returns
[]
我的代码:
def in_array(array1, array2):
r = []
for a1 in