You are given an array of strings chunks. The strings are concatenated in order to form a single string s.
You are also given an array of strings queries.
A word is defined as a substring of s that:
'a' to 'z'),'-') only if each hyphen is surrounded by lowercase English letters, andAny character that is not a lowercase English letter or a valid hyphen acts as a separator.
Return an integer array ans such that ans[i] is the number of occurrences of queries[i] as a word in s.
A substring is a contiguous non-empty sequence of characters within a string.
Example 1:
Input: chunks = ["hello wor","ld hello"], queries = ["hello","world","wor"]
Output: [2,1,0]
Explanation:
chunks gives s = "hello world hello".s are "hello" which appears twice and "world" which appears once.ans = [2, 1, 0].Example 2:
Input: chunks = ["a--b a-","-c"], queries = ["a","b","c"]
Output: [2,1,1]
Explanation:
chunks gives s = "a--b a--c".s are "a" which appears twice, "b" which appears once, and "c" which appears once.ans = [2, 1, 1].Example 3:
Input: chunks = ["hello"], queries = ["hello","ell"]
Output: [1,0]
Explanation:
s is "hello" which appears once.ans = [1, 0].Constraints:
1 <= chunks.length <= 1051 <= chunks[i].length <= 105chunks[i] may consist of lowercase English letters, spaces, and hyphens.chunks does not exceed 1051 <= queries.length <= 1051 <= queries[i].length <= 105queries[i] is a valid wordqueries does not exceed 105Loading editor...
["hello wor","ld hello"] ["hello","world","wor"]