描述
判断短字符串S中的所有字符是否在长字符串T中全部出现。
输入描述:
输入两个字符串。第一个为短字符串,第二个为长字符串。两个字符串均由小写字母组成。
输出描述:
如果短字符串的所有字符均在长字符串中出现过,则输出字符串"true"。否则输出字符串"false"。
输入:
bc
abc
输出:
true
说明:
其中abc含有bc,输出"true"
let arr = []
while(line = await readline()){
arr.push(line)
}
let firstArr = arr[0].split('')
let count = new Array(arr[0].length).fill(0)
firstArr.map((item,index)=>{
let reg = new RegExp(item,'g')
let length = arr[1].match(reg)
count[index] = length?length.length:0
})
console.log(!!Math.min(...count))
网友评论